3 Replies Latest reply on Jun 7, 2012 8:30 AM by ranjani k

    JMSException in onMessage(): javax.jms.JMSException

    ranjani k Newbie

      hi
      im trying to send object through jms queue..

       

      <code>
      public void onMessage(Message queuemessage) {
      try {
      if (queuemessage instanceof ObjectMessage) {
      ObjectMessage Objmsg = (ObjectMessage) queuemessage;
      System.out.println(((ObjectMessage)queuemessage).getJMSDestination());
      System.out.println(((ObjectMessage)queuemessage).getJMSMessageID());
      Object objectData = ((ObjectMessage)queuemessage).getObject(); // i'm getting exception in this line
      if (objectData instanceof TestClass) {
      TestClass s1 = (TestClass) objectData;
      System.out.println("Reading message s1: " +s1.getEid());
      }

      </code>

       

       

      TestClass implements java.io.Serializable. im using jboss-6.0.0.final
      im not getting this exception when i sent String object.

      im getting JMSDestination ,JMSMessageID  from the queuemessage. It throws exception in getObject() method.
      How to get my  testclass object in onmessage method??? What is wrong in the code?

      I have attached my code.

       

      Please suggest.

       

      Exception:

       

      17:35:02,611 INFO [STDOUT] HornetQQueue[Myqueue1]

       

      17:35:09,197 INFO [STDOUT] ID:a242b9ff-aede-11e1-9332-00016c4d854e


      17:39:58,209 ERROR [STDERR] javax.jms.JMSException: com.test.TestClass

      17:39:58,209 ERROR [STDERR] at java.net.URLClassLoader$1.run(Unknown Source)

      17:39:58,209 ERROR [STDERR] at java.net.URLClassLoader$1.run(Unknown Source)

      17:39:58,209 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)

      17:39:58,209 ERROR [STDERR] at java.net.URLClassLoader.findClass(Unknown Source)

      17:39:58,209 ERROR [STDERR] at java.lang.ClassLoader.loadClass(Unknown Source)

      17:39:58,209 ERROR [STDERR] at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

      17:39:58,209 ERROR [STDERR] at java.lang.ClassLoader.loadClass(Unknown Source)

      17:39:58,209 ERROR [STDERR] at java.lang.Class.forName0(Native Method)

      17:39:58,209 ERROR [STDERR] at java.lang.Class.forName(Unknown Source)

      17:39:58,209 ERROR [STDERR] at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:284)

      17:39:58,209 ERROR [STDERR] at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1152)

      17:39:58,210 ERROR [STDERR] at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:886)

      17:39:58,210 ERROR [STDERR] at org.jboss.classloader.spi.base.BaseClassLoader.doLoadClass(BaseClassLoader.java:505)

      17:39:58,219 ERROR [STDERR] at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:450)

      17:39:58,219 ERROR [STDERR] at java.lang.ClassLoader.loadClass(Unknown Source)

      17:39:58,219 ERROR [STDERR] at java.lang.Class.forName0(Native Method)

      17:39:58,219 ERROR [STDERR] at java.lang.Class.forName(Unknown Source)

      17:39:58,219 ERROR [STDERR] at java.io.ObjectInputStream.resolveClass(Unknown Source)

      17:39:58,219 ERROR [STDERR] at org.hornetq.utils.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:69)

      17:39:58,219 ERROR [STDERR] at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)

      17:39:58,220 ERROR [STDERR] at java.io.ObjectInputStream.readClassDesc(Unknown Source)

      17:39:58,220 ERROR [STDERR] at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)

      17:39:58,220 ERROR [STDERR] at java.io.ObjectInputStream.readObject0(Unknown Source)

      17:39:58,220 ERROR [STDERR] at java.io.ObjectInputStream.readObject(Unknown Source)

      17:39:58,220 ERROR [STDERR] at org.hornetq.jms.client.HornetQObjectMessage.getObject(HornetQObjectMessage.java:158)

      17:39:58,220 ERROR [STDERR] at com.test.Sender.onMessage(Sender.java:91)

      17:39:58,220 ERROR [STDERR] at org.hornetq.jms.client.JMSMessageListenerWrapper.onMessage(JMSMessageListenerWrapper.java:91)

      17:39:58,221 ERROR [STDERR] at org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:822)

      17:39:58,221 ERROR [STDERR] at org.hornetq.core.client.impl.ClientConsumerImpl.access$100(ClientConsumerImpl.java:46)

      17:39:58,221 ERROR [STDERR] at org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:940)

      17:39:58,221 ERROR [STDERR] at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:100)

      17:39:58,221 ERROR [STDERR] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

      17:39:58,221 ERROR [STDERR] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

      17:39:58,221 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)

       

        • 1. Re: JMSException in onMessage(): javax.jms.JMSException
          Bernd Eckenfels Novice

          im trying to send object through jms queue..

           

          <code>
          public void onMessage(Message queuemessage) {
          try {
          Object objectData = ((ObjectMessage)queuemessage).getObject(); // i'm getting exception in this line

           

          It looks like you are not trying to send a JMS Message, but to receive it.

           

          The Exception you are seeing looks like the Java Class your Object is from (and all other Java Classes used in that Object Message) are not available in the classpath of the message driven bean. You need to package all data value classes (and others for example possible exceptions this object may throw) together with your enterprise application who should receive the message.

           

          But it is better to avoid ObjectMessages at all, since you lose a lot of the lose coupling properties of a MOM.

           

          Gruss

          Bernd

          • 3. Re: JMSException in onMessage(): javax.jms.JMSException
            ranjani k Newbie

            thanks for your reply..

            i have gone through the discussions in the link https://issues.jboss.org/browse/AS7-1271

            i found this issue can be solved by commenting

            <bean name="WarClassLoaderDeployer" class="org.jboss.web.tomcat.service.deployers.WarClassLoaderDeployer">
                  <property name="relativeOrder">-1</property>
                  <property name="filteredPackages">javax.servlet</property>     
            </bean> in war-deployers-jboss-beans.xml file

            or

            changing the classloader programatically.

            <code>

            ClassLoader originalTCCL = Thread.currentThread().getContextClassLoader();

            try
            {
               
            // temporarily change TCCL
                Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());

                ObjectMessage om = (ObjectMessage) message;
                logger.info(
            "ObjectMessage Created");
                Student s = (Student) om.getObject();
                logger.info(
            "Student created");
                logger.info(s.toString());
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
            finally
            {
               
            // set back the original TCCL
                Thread.currentThread().setContextClassLoader(originalTCCL);
            }

            </code>

            above option is not working for me..

            I have tried the first one. After made changes in war-deployers-jboss-beans.xml i tried to debug..when it

            reaches onmessage() method  debug pop stands  in Daemon Thread [http-127.0.0.1-8080-1] (Stepping) 

            In the variable dialog its showing    [toString() unavailable - no suspended threads]   for all the variables. I could not debug further.

            There is no stack trace on the console..Previously jmsexception was displayed on the console.

            I reverted the changes in war-deployers-jboss-beans.xml ..I reinstalled the jboss. still everytime i debug

            i'm getting the same.. please tel what could be the cause for it?

            I couldn't proceed further..