6 Replies Latest reply on Apr 23, 2002 5:36 AM by laxmanrao

    QueueConnection.close does not clean up all threads

    Jim Hazen Expert

      From what I can tell, in the latest cvs HEAD QueueConnection.close does not clean up all it's threads. I have a program which creates a connection, starts the connection, then stops and closes the connection. The program then never exits. If I instead do not create the connection at all, the program exits. I believe this is due to QueueConnection creating non daemon threads that are never cleaned up. This prevents the JVM from exiting even though I've run out of executable code.

        • 1. Re: QueueConnection.close does not clean up all threads
          Jim Hazen Expert

          Hmm, this may also be a side effect of the QueueConnection ping code. It may spawn a thread to ping the queue every so often. This thread should be cleaned up when there are no longer any connections running. And then recreated if another connection is made down the road.

          • 2. Re: QueueConnection.close does not clean up all threads
            Jim Hazen Expert

            or be made a daemon thread...

            • 3. Re: QueueConnection.close does not clean up all threads
              Hiram Chirino Expert

              Yes... you are right.. It is the new ping thread.. I need to change it so that it is a deamon thread.

              • 4. Re: QueueConnection.close does not clean up all threads
                Hiram Chirino Expert

                This has now been fixed in the CVS HEAD branch.

                • 5. Re: QueueConnection.close does not clean up all threads
                  laxmanrao Newbie

                  I have a similar problem and the description is as given below. When I send an item to a queue JBOSS is creating a thread that is never killed. Is this a problem with JBOSS or do I need to change the code from my side.

                  TRANSACTION ROLLBACK EXCEPTION:
                  javax.transaction.TransactionRolledbackException: unable to create new native thread; nested exception is:
                  java.lang.OutOfMemoryError: unable to create new native thread
                  java.lang.OutOfMemoryError: unable to create new native thread
                  at java.lang.Thread.start(Native Method)
                  at org.jboss.mq.il.oil.OILClientILService.start(OILClientILService.java:81)
                  at org.jboss.mq.Connection.startILService(Connection.java:504)
                  at org.jboss.mq.Connection.(Connection.java:129)
                  at org.jboss.mq.Connection.(Connection.java:145)
                  at org.jboss.mq.SpyConnection.(SpyConnection.java:58)
                  at org.jboss.mq.SpyConnectionFactory.createQueueConnection(SpyConnectionFactory.java:89)
                  at teaminetwork.bpi.runtime.queue.jboss.JBossAdapter.init(JBossAdapter.java:2044)
                  at teaminetwork.bpi.runtime.queue.jboss.JBossAdapter.createQueue(JBossAdapter.java:297)
                  at teaminetwork.bpi.runtime.queue.BPIQueue.(BPIQueue.java:109)
                  at teaminetwork.bpi.runtime.events.Event.setEvent(Event.java:215)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:542)
                  at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:82)
                  at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:138)
                  at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:347)
                  at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:100)
                  at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
                  at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
                  at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:286)
                  at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:410)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
                  at sun.rmi.transport.Transport$1.run(Transport.java:152)
                  at java.security.AccessController.doPrivileged(Native Method)
                  at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
                  at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
                  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
                  at java.lang.Thread.run(Thread.java:484)

                  Thanx in advance
                  Laxman

                  • 6. Re: QueueConnection.close does not clean up all threads
                    laxmanrao Newbie

                    Hi All,
                    Adding to the above mentioned problem when I tried to run the same with jboss2.2.2_tomcat3.2.2 it gave the following error
                    [JBossMQ] Closing socket: Initialisation
                    [JBossMQ] java.net.SocketException: Too many open files
                    [JBossMQ] at java.net.PlainSocketImpl.socketAccept(Native Method)
                    [JBossMQ] at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:421)
                    [JBossMQ] at java.net.ServerSocket.implAccept(ServerSocket.java:243)
                    [JBossMQ] at java.net.ServerSocket.accept(ServerSocket.java:222)
                    [JBossMQ] at org.jbossmq.distributed.server.DistributedJMSServerOIL.run(DistributedJMSServerOIL.java:72)
                    [JBossMQ] at java.lang.Thread.run(Thread.java:484)
                    [Event] java.io.StreamCorruptedException: Caught EOFException while reading the stream header
                    [Event] at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:845)
                    [Event] at java.io.ObjectInputStream.(ObjectInputStream.java:168)
                    [Event] at org.jbossmq.distributed.server.DistributedJMSServerOILClient.createConnection(DistributedJMSServerOILClient.java:66)
                    [Event] at org.jbossmq.distributed.server.DistributedJMSServerOILClient.checkConnection(DistributedJMSServerOILClient.java:76)
                    [Event] at org.jbossmq.distributed.server.DistributedJMSServerUILClient.getID(DistributedJMSServerUILClient.java:131)
                    [Event] at org.jbossmq.SpyConnection.askForAnID(SpyConnection.java:339)
                    [Event] at org.jbossmq.SpyConnection.createReceiver(SpyConnection.java:362)
                    [Event] at org.jbossmq.SpyQueueConnection.createQueueSession(SpyQueueConnection.java:47)
                    [Event] at teaminetwork.bpi.runtime.queue.jboss.JBossAdapter.init(JBossAdapter.java:2045)
                    [Event] at teaminetwork.bpi.runtime.queue.jboss.JBossAdapter.createQueue(JBossAdapter.java:297)
                    [Event] at teaminetwork.bpi.runtime.queue.BPIQueue.(BPIQueue.java:109)
                    [Event] at teaminetwork.bpi.runtime.events.Event.setEvent(Event.java:215)
                    [Event] at java.lang.reflect.Method.invoke(Native Method)
                    [Event] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:472)
                    [Event] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:87)
                    [Event] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133)
                    [Event] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:263)
                    [Event] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
                    [Event] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:190)
                    [Event] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
                    [Event] at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:271)
                    [Event] at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:392)
                    [Event] at java.lang.reflect.Method.invoke(Native Method)
                    [Event] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
                    [Event] at sun.rmi.transport.Transport$1.run(Transport.java:152)
                    [Event] at java.security.AccessController.doPrivileged(Native Method)
                    [Event] at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
                    [Event] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
                    [Event] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
                    [Event] at java.lang.Thread.run(Thread.java:484)
                    [Event] java.rmi.RemoteException: Cannot contact the remote object
                    [Event] at org.jbossmq.distributed.server.DistributedJMSServerUILClient.failure(DistributedJMSServerUILClient.java:127)
                    [Event] at org.jbossmq.distributed.server.DistributedJMSServerOILClient.createConnection(DistributedJMSServerOILClient.java:70)
                    [Event] at org.jbossmq.distributed.server.DistributedJMSServerOILClient.checkConnection(DistributedJMSServerOILClient.java:76)
                    [Event] at org.jbossmq.distributed.server.DistributedJMSServerUILClient.getID(DistributedJMSServerUILClient.java:131)
                    [Event] at org.jbossmq.SpyConnection.askForAnID(SpyConnection.java:339)
                    [Event] at org.jbossmq.SpyConnection.createReceiver(SpyConnection.java:362)
                    [Event] at org.jbossmq.SpyQueueConnection.createQueueSession(SpyQueueConnection.java:47)
                    [Event] at teaminetwork.bpi.runtime.queue.jboss.JBossAdapter.init(JBossAdapter.java:2045)
                    [Event] at teaminetwork.bpi.runtime.queue.jboss.JBossAdapter.createQueue(JBossAdapter.java:297)
                    [Event] at teaminetwork.bpi.runtime.queue.BPIQueue.(BPIQueue.java:109)
                    [Event] at teaminetwork.bpi.runtime.events.Event.setEvent(Event.java:215)
                    [Event] at java.lang.reflect.Method.invoke(Native Method)

                    Thanx in advance
                    Laxman