2 Replies Latest reply on Oct 19, 2004 8:14 AM by umar

    JMS in Applets

    umar

      I have a problem in an applet client of jbossmq. This is the same bug as in
      http://jboss.org/index.html?module=bb&op=viewtopic&t=40438

      The Connection class uses a static ThreadGroup which gets destroyed
      by the Browser on reload, and the code is not capable to reinitialise it.

      java.lang.NoClassDefFoundError
       at org.jboss.mq.SpyJMSException.<init>(SpyJMSException.java:79)
       at org.jboss.mq.Connection.authenticate(Connection.java:1168)
       at org.jboss.mq.Connection.<init>(Connection.java:255)
       at org.jboss.mq.Connection.<init>(Connection.java:332)
       at org.jboss.mq.SpyConnection.<init>(SpyConnection.java:66)
       at org.jboss.mq.SpyConnectionFactory.createConnection(SpyConnectionFactory.java:87)
       at ch.steria.tbazh.applet.TestApplet.listen(TestApplet.java:97)
       at ch.steria.tbazh.applet.TestApplet.init(TestApplet.java:34)
       at sun.applet.AppletPanel.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)
      
      


      The exception is an inherited error. If I grant all permissions in the browsers java.policy, the Exception disapeares, but the connection goes up only on every 2. reload.

      It happens with IE6 && Mozilla 1.6. I use JRE1.5 and JBoss 4.0.

       private void listen() throws JMSException, NamingException {
       initialContext = getInitialContext(getDocumentBase().getHost());
       TopicConnectionFactory topic = (TopicConnectionFactory)initialContext.lookup("ConnectionFactory");
       connection = topic.createConnection();
       // ^ here
       session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
       Destination destination = (Destination)initialContext.lookup("topic/testTopic");
       messageConsumer = session.createConsumer(destination);
       messageConsumer.setMessageListener(this);
       connection.start();
       }
      


      If this is a bug, has somebody a workaround or knows an available patch?
      Thanks in advance.



        • 1. Re: JMS in Applets

          More wild assertions.
          The bug you link to has already been fixed in JBoss4.

          The error message says you are missing a class.
          I have no idea why the JDK in your browser isn't you telling the class that is missing?

          But if you look at the source code,

          org.jboss.mq.SpyJMSException.<init>(SpyJMSException.java:79)
          

          http://cvs.sourceforge.net/viewcvs.py/jboss/jbossmq/src/main/org/jboss/mq/SpyJMSException.java?annotate=1.7
          you will see it is NestedThrowable.Util which is in jboss-commons.jar

          • 2. Re: JMS in Applets
            umar

            Right. This bug is fixed. While debugging, I found this exception:

            org.jboss.mq.SpyJMSException: Cannot disable the connection with the JMS server;
             - nested throwable: (java.io.IOException: Client is not connected)
             at org.jboss.mq.Connection.doStop(Connection.java:1289)
             at org.jboss.mq.Connection.stop(Connection.java:718)
             at ch.steria.tbazh.applet.TestApplet.stop(TestApplet.java:57)
             at sun.applet.AppletPanel.run(Unknown Source)
             at java.lang.Thread.run(Unknown Source)
            Caused by: java.io.IOException: Client is not connected
             at org.jboss.mq.il.uil2.SocketManager.internalSendMessage(SocketManager.java:226)
             at org.jboss.mq.il.uil2.SocketManager.sendMessage(SocketManager.java:192)
             at org.jboss.mq.il.uil2.UILServerIL.setEnabled(UILServerIL.java:162)
             at org.jboss.mq.Connection.doStop(Connection.java:1285)
             ... 4 more
            

            It only happens with more than one applet with the same code on a single webpage. I use now signed applets, the NoClassDefFoundError disapeared.
            Before the reload, the applets are able to print JMS messages to stdout, so there are connections to JBossMQ.

            I think there is a race condition in the connection code. The source of a demo applet, a html document and the necessary jars are available:
            http://www.marti.nu/applet/
            There is no JMS service running there. So the applet will not work.

            Is this behavior reproducible and is it possible to fix it?
            Thank you.

            -Marti