4 Replies Latest reply on Feb 13, 2004 1:27 PM by e4muell1

    Applet JMS Problem

    bobbysun

      When Applet destroyes and reinit in one session(the same java console), or refresh applet's web page, I will get this error:

      org.jboss.mq.SpyJMSException: Cannot start a the client IL service; - nested throwable: (java.lang.IllegalThreadStateException)

      at org.jboss.mq.Connection.startILService(Connection.java:962)

      at org.jboss.mq.Connection.(Connection.java:249)

      at org.jboss.mq.Connection.(Connection.java:315)

      at org.jboss.mq.SpyConnection.(SpyConnection.java:60)

      at org.jboss.mq.SpyConnectionFactory.createTopicConnection(SpyConnectionFactory.java:78)

      at com.wondersgroup.ocddemo.applet.MsgConsole.msgSubscribe(MsgConsole.java:293)

      at com.wondersgroup.ocddemo.applet.MsgConsoleApplet.init(MsgConsoleApplet.java:32)

      at sun.applet.AppletPanel.run(Unknown Source)

      at java.lang.Thread.run(Unknown Source)

      Caused by: java.lang.IllegalThreadStateException

      at java.lang.ThreadGroup.add(Unknown Source)

      at java.lang.Thread.init(Unknown Source)

      at java.lang.Thread.(Unknown Source)

      at org.jboss.mq.il.oil.OILClientILService.start(OILClientILService.java:295)

      at org.jboss.mq.Connection.startILService(Connection.java:954)

      ... 8 more


      This info. is about OILConnectionFactory. I have tried UIL and UIL2 too, UIL has same problem, UIL2 is no any response.

      The only solution I found is press 'x' in the java console, clear classloader cache, then everything is OK, but I think it equals a new init.

      Who can help me? Thanks!

        • 1. Re: Applet JMS Problem

          Without seeing the part of your code that handles JMS connections, I doubt someone could help you.

          Regards,

          Stephane

          • 2. Re: Applet JMS Problem
            bobbysun

            You're right!

            Code snippet:

            public class MsgConsole extends JPanel {
            ......
            ......
            protected void msgSubscribe() {
            try {
            InitialContext ctx = getContext();

            TopicConnectionFactory factory = (TopicConnectionFactory) ctx.lookup("ConnectionFactory");
            /* TopicConnectionFactory factory = (TopicConnectionFactory) ctx.lookup("UIL2ConnectionFactory");
            */

            topic = (Topic)ctx.lookup("topic/ocdMsgTopic");

            connection = factory.createTopicConnection();

            session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

            TopicSubscriber subscriber = session.createSubscriber(topic);
            subscriber.setMessageListener(new MessageListener() {
            public void onMessage(Message msg) {
            procMessage(msg);
            }
            });

            connection.start();
            } catch (Exception e) {
            e.printStackTrace();
            }

            }

            protected void msgUnSubscribe() {
            try {
            connection.stop();

            session.close();
            connection.close();
            }
            catch (Exception e) {
            e.printStackTrace();
            }
            }

            ......
            ......
            }


            Applet Code Snippet:

            public class MsgConsoleApplet extends JApplet {

            MsgConsole mc = new MsgConsole();

            public void init() {

            System.out.println("MsgConsoleApplet Init");
            getContentPane().add(mc);
            String operatorID = getParameter("operatorID");
            System.out.println("operatorID: " + operatorID);
            String role = getParameter("role");
            System.out.println("role: " + role);
            mc.setOperatorID(operatorID);
            mc.setRole(role);

            mc.msgSubscribe();
            }

            public void start() {

            System.out.println("MsgConsoleApplet Start");
            }

            public void stop() {

            System.out.println("MsgConsoleApplet Stop");
            mc.msgUnSubscribe();
            }

            public void destroy() {

            System.out.println("MsgConsoleApplet Destroy");
            }
            }

            Regards

            Bobby

            • 3. Re: Applet JMS Problem
              sulfur

              Hi just wondering of anyone has a solution.

              I have the exact same problem using Netscape 7.1/Mozilla 1.4 but the applet code works perfectly in IE 6. Is there a known issue with Mozilla?

              Using JBoss 3.2.1-Tomcat 4.1.24 & JDK 1.4.2. Applet trusted via self signed JARs.

              I have a standard applet with init(), start(), stop(), destroy(). I noticed both Mozilla & IE will stop & destroy applet on page exit or refresh. My code does explicitly stop & close the TopicConnection & Session.

              I've tried OIL & UIL2 and got similar errors.

              Stack Trace w/ OIL:

              DEBUG [thread myClass] (SpyConnectionFactoryObjectFactory.java:44) - Extracting SpyConnectionFactory from reference

              DEBUG [thread myClass] (SpyConnectionFactoryObjectFactory.java:52) - The GenericConnectionFactory is: GenericConnectionFactory:[server=org.jboss.mq.il.oil.OILServerIL@1898115,connectionProperties={OIL_TCPNODELAY_KEY=yes, PingPeriod=60000, OIL_PORT_KEY=8090, ClientILService=org.jboss.mq.il.oil.OILClientILService, OIL_ADDRESS_KEY=172.16.125.217}]

              DEBUG [thread myClass] (GenericConnectionFactory.java:75) - Handing out ClientIL: org.jboss.mq.il.oil.OILClientILService

              DEBUG [thread myClass] (Connection.java:961) - Cannot start a the client IL service

              java.lang.IllegalThreadStateException

              at java.lang.ThreadGroup.add(Unknown Source)

              at java.lang.Thread.init(Unknown Source)

              at java.lang.Thread.(Unknown Source)

              at org.jboss.mq.il.oil.OILClientILService.start(OILClientILService.java:295)

              at org.jboss.mq.Connection.startILService(Connection.java:954)

              at org.jboss.mq.Connection.(Connection.java:249)

              at org.jboss.mq.Connection.(Connection.java:315)

              at org.jboss.mq.SpyConnection.(SpyConnection.java:59)

              at org.jboss.mq.SpyConnectionFactory.createTopicConnection(SpyConnectionFactory.java:78)

              (...snip...)

              DEBUG [thread myClass] (NestedThrowable.java:128) - org.jboss.util.NestedThrowable.parentTraceEnabled=true

              DEBUG [thread myClass] (NestedThrowable.java:128) - org.jboss.util.NestedThrowable.nestedTraceEnabled=false

              DEBUG [thread myClass] (NestedThrowable.java:128) - org.jboss.util.NestedThrowable.detectDuplicateNesting=true

              Thanks,

              Anthony.

              • 4. Re: Applet JMS Problem
                e4muell1

                Hi

                We have the same problem and found out that this is a bug in JBoss. The problem is complex:

                - Browsers use the same virtual machine for different applets. They use different classloaders for different sites and same class loaders for same site. So far no problem.

                - BUT: If an applet is loaded and another page is displayed (where there is no applet), the Applet.destroy() method is called AND the virtual machine destroys ALL the threads and THREAD GROUPS!

                - And here comes the bug: OILClientILService uses a static THREAD GROUP where it adds a new thread when starting. But this thread is DESTROYED when re-visiting the applet. -> BUM, IllegalThreadStateException.

                Sad that JBoss still is not production capable.

                Regards,
                Stefan