IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Tomcat et TomEE Java Discussion :

unable to create new native thread


Sujet :

Tomcat et TomEE Java

  1. #1
    Membre habitué
    Avatar de jeha
    Inscrit en
    Octobre 2005
    Messages
    127
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 127
    Points : 193
    Points
    193
    Par défaut unable to create new native thread
    bonjour mes amis, j'ai un problème avec l'erreur unable to create new native thread

    SEVERE: java.lang.OutOfMemoryError: unable to create new native thread
    at java.lang.Thread.start0(Native Method)
    at java.lang.Thread.start(Thread.java:597)
    at sun.rmi.transport.DGCClient$EndpointEntry.<init>(DGCClient.java:231)
    at sun.rmi.transport.DGCClient$EndpointEntry.lookup(DGCClient.java:202)
    at sun.rmi.transport.DGCClient.registerRefs(DGCClient.java:120)
    at sun.rmi.transport.LiveRef.read(LiveRef.java:294)
    at sun.rmi.server.UnicastRef2.readExternal(UnicastRef2.java:59)
    at java.rmi.server.RemoteObject.readObject(RemoteObject.java:438)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at java.rmi.MarshalledObject.get(MarshalledObject.java:142)
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:257)
    at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at ma.hps.pcrd.gateway.controller.UserProfileController.isMerchantUser(UserProfileController.java:105)
    at ma.hps.pcrd.gateway.view.bean.UserBean.logIn(UserBean.java:273)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.el.parser.AstValue.invoke(AstValue.java:172)
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
    at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
    at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:99)
    at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:771)
    at javax.faces.component.UICommand.broadcast(UICommand.java:372)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
    :$
    at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:160)
    at com.icesoft.faces.webapp.http.servlet.SessionDispatcher$1.service(SessionDispatcher.java:42)
    at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
    at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:63)
    at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:62)
    at com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:22)
    at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
    at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:153)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:56)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    at java.lang.Thread.run(Thread.java:619)

    dans le fichier catalina.sh j'ai
    JAVA_OPTS="$JAVA_OPTS -Xms128m -Xmx1000m"

    et le serveur tomcat démarre avec les informations:
    webuser 25396 1 0 10:14 ? 00:00:27 /usr/java/jdk1.6.0_20/bin/java -Djava.util.logging.config.file=/home/webuser/apache-tomcat-6.0.20/conf/logging.properties -Xms128m -Xmx1000m -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/home/webuser/apache-tomcat-6.0.20/endorsed -classpath :/home/webuser/apache-tomcat-6.0.20/bin/bootstrap.jar -Dcatalina.base=/home/webuser/apache-tomcat-6.0.20 -Dcatalina.home=/home/webuser/apache-tomcat-6.0.20 -Djava.io.tmpdir=/home/webuser/apache-tomcat-6.0.20/temp org.apache.catalina.startup.Bootstrap start

    dans le fichier de conf/serveur.xml:

    <?xml version='1.0' encoding='utf-8'?>
    <!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements. See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
    -->
    <!-- Note: A "Server" is not itself a "Container", so you may not
    define subcomponents such as "Valves" at this level.
    Documentation at /docs/config/server.html
    -->
    <Server port="8005" shutdown="SHUTDOWN">

    <!--APR library loader. Documentation at /docs/apr.html -->
    <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
    <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
    <Listener className="org.apache.catalina.core.JasperListener" />
    <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
    <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

    <!-- Global JNDI resources
    Documentation at /docs/jndi-resources-howto.html
    -->
    <GlobalNamingResources>
    <!-- Editable user database that can also be used by
    UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
    type="org.apache.catalina.UserDatabase"
    description="User database that can be updated and saved"
    factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
    pathname="conf/tomcat-users.xml" />
    </GlobalNamingResources>

    <!-- A "Service" is a collection of one or more "Connectors" that share
    a single "Container" Note: A "Service" is not itself a "Container",
    so you may not define subcomponents such as "Valves" at this level.
    Documentation at /docs/config/service.html
    -->
    <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
    maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
    and responses are returned. Documentation at :
    Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
    Java AJP Connector: /docs/config/ajp.html
    APR (HTTP/AJP) Connector: /docs/apr.html
    Define a non-SSL HTTP/1.1 Connector on port 8080
    -->

    <Connector port="8080" protocol="HTTP/1.1"
    connectionTimeout="20000" maxThreads="500"
    />

    <!--
    <Connector port="443" minSpareThreads="5" maxSpareThreads="75" enableLookups="true" disableUploadTimeout="true" acceptCount="100" maxThreads="200" scheme="https" secure="true" SSLEnabled="true" keystoreFile="/home/webuser/apache-tomcat-6.0.20/conf/cert.p12" keystoreType="PKCS12" keystorePass="tomcat" clientAuth="false" sslProtocol="TLS"/>

    -->
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
    This connector uses the JSSE configuration, when using APR, the
    connector should be using the OpenSSL style configuration
    described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
    maxThreads="500" scheme="https" secure="true"
    clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
    every request. The Engine implementation for Tomcat stand alone
    analyzes the HTTP headers included with the request, and passes them
    on to the appropriate Host (virtual host).
    Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
    -->
    <Engine name="Catalina" defaultHost="localhost">

    <!--For clustering, please take a look at documentation at:
    /docs/cluster-howto.html (simple how to)
    /docs/config/cluster.html (reference documentation) -->
    <!--
    <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
    -->

    <!-- The request dumper valve dumps useful debugging information about
    the request and response data received and sent by Tomcat.
    Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
    -->

    <!-- This Realm uses the UserDatabase configured in the global JNDI
    resources under the key "UserDatabase". Any edits
    that are performed against this UserDatabase are immediately
    available for use by the Realm. -->
    <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
    resourceName="UserDatabase"/>

    <!-- Define the default virtual host
    Note: XML Schema validation will not work with Xerces 2.2.
    -->
    <Host name="localhost" appBase="webapps"
    unpackWARs="true" autoDeploy="true"
    xmlValidation="false" xmlNamespaceAware="false">

    <!-- SingleSignOn valve, share authentication between web applications
    Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->

    <!-- Access log processes all example.
    Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
    prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
    -->

    </Host>
    </Engine>
    </Service>
    </Server>
    tomcat est installé dans linux redhat.
    avec java 1.6.

    et quand j'exécute la commande ulimit j'ai:
    core file size (blocks, -c) 0
    data seg size (kbytes, -d) unlimited
    scheduling priority (-e) 0
    file size (blocks, -f) unlimited
    pending signals (-i) 118783
    max locked memory (kbytes, -l) 32
    max memory size (kbytes, -m) unlimited
    open files (-n) 1024
    pipe size (512 bytes, -p) 8
    POSIX message queues (bytes, -q) 819200
    real-time priority (-r) 0
    stack size (kbytes, -s) 10240
    cpu time (seconds, -t) unlimited
    max user processes (-u) 100
    virtual memory (kbytes, -v) unlimited
    file locks (-x) unlimited
    Merci de m'aider pour résoudre ce problème et comment faire?

  2. #2
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    tu a soit atteinds la limite du nombre de threads par process autorisé par l'os (vérifie /proc/sys/kernel/threads-max), soit le nombre de thread*taille de la stack = limite de mémoire autorisée pour la jvm

  3. #3
    Membre habitué
    Avatar de jeha
    Inscrit en
    Octobre 2005
    Messages
    127
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 127
    Points : 193
    Points
    193
    Par défaut
    le threads-max dans sys est: 32768


    j'ai dégât modifie JAVA_OPTS="$JAVA_OPTS -Xms128m -Xmx1000m" dans bin/catalina.sh et Xss par défaut 512k
    et j'ai installé JDK 1.6 pour avoir plus de mémoire pour les process :

    java version "1.6.0_20"
    Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
    Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)

    donc j'ai environ plus 3Go pour un processus sur l'OS alors que (MaxProcessMemory - JVMMemory - ReservedOsMemory) / (ThreadStackSize) = Number of threads nous donne environ 4066 threads, et quand j'execute la commande pstree -p il y a seulement 48 to 94 thread créer par java !!!!! et si le nombre dépasse 97 thead il y a le problème de unable to create new native thread !!!


    merci chef.

  4. #4
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    Essaie de diminuer la valeur de Xss pour commencer.

    Les erreurs ont toujours lieu au même endroit? Ca pourrait etre une demande de thread en pic qui poserait problème. J'ai déjà eu le coup d'un librairie qui, sur un demi seconde, créait 500 threads et le libérait immédiatement après :s

  5. #5
    Membre habitué
    Avatar de jeha
    Inscrit en
    Octobre 2005
    Messages
    127
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 127
    Points : 193
    Points
    193
    Par défaut
    j'ai exécute ce scripte dans tomcat et il ma donne unable to create new native thread apres 57 thread seulement !!!!!!!!

    import java.util.concurrent.CountDownLatch;

    public class TestNativeOutOfMemoryError {

    public static void main(String[] args) {

    for (int i = 0;; i++) {
    System.out.println("i = " + i);
    new Thread(new HoldThread()).start();
    }
    }

    }

    class HoldThread extends Thread {
    CountDownLatch cdl = new CountDownLatch(1);

    public HoldThread() {
    this.setDaemon(true);
    }

    public void run() {
    try {
    cdl.await();
    } catch (InterruptedException e) {
    }
    }
    }
    le meme test, sur mon PC j'ai 12896 thread !!!!

    est ce qu'il y a une commande dans linux pour faire une restriction sur le nombre de thread par user ???

  6. #6
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    d'après un vieux post chez suse, le nombre max de threads d'un process semble etre limité par ulimit comme étant "max user processes" -43, ce qui dans ton cas tournerais autour de 57, bingo!


    Augmente donc la limite dans le nombre de processes.... (A noter que Threads et process sont gérés de manière similaires par le noyau!)

  7. #7
    Membre habitué
    Avatar de jeha
    Inscrit en
    Octobre 2005
    Messages
    127
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 127
    Points : 193
    Points
    193
    Par défaut
    Bonjour,

    c'est vrai chef d'après la commande ulimit -u j'ai :


    max user processes (-u) 100

    donc pour résoudre ce problème j'ai modifié le fichier /etc/security/limits.conf

    #<domain> <type> <item> <value>
    user soft nproc 10000
    user hard nproc 10000


    et c'est ok, le problème est résolu.

    merci chef.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Unable to create a new writer
    Par ramijrad dans le forum Tomcat et TomEE
    Réponses: 0
    Dernier message: 05/04/2011, 18h40
  2. Réponses: 1
    Dernier message: 03/10/2006, 11h21
  3. unable to create variable object
    Par Batou dans le forum C++
    Réponses: 2
    Dernier message: 09/05/2006, 07h49
  4. Réponses: 4
    Dernier message: 21/11/2005, 12h04
  5. unable to create INITIAL extent for segment in tablespace
    Par Ludolitaliano dans le forum Administration
    Réponses: 4
    Dernier message: 11/09/2003, 16h43

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo