7 Replies Latest reply on Jul 11, 2012 4:55 AM by Jeff Mesnil

    HornetQ can't resolve class of ObjectMessage payload.

    kjh21 Newbie

      Following is my environment

       

      JBossAS [6.0.0.Final "Neo"]

      HornetQ Server version 2.1.2.Final (Colmeia, 120)

       

      I'm getting the same error described here

       

      http://community.jboss.org/message/517604#517604

       

      and here

       

      http://community.jboss.org/thread/162024

       

       

      Specifically, HornetQ is unable to resolve the class of an object that serves as the payload of an ObjectMessage.

       

      The exception and stack trace are as follows:

       

      477 SEVERE [toplevel.services.push.ProxyMessageListener] Caught Exception processing incoming message:  javax.jms.JMSException: toplevel.services.heartbeat.Heartbeat

      01:18:36,477 ERROR [STDERR] javax.jms.JMSException: toplevel.services.heartbeat.Heartbeat

       

      01:18:36,477 ERROR [STDERR]     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

       

      01:18:36,477 ERROR [STDERR]     at java.security.AccessController.doPrivileged(Native Method)

       

      01:18:36,477 ERROR [STDERR]     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

       

      01:18:36,477 ERROR [STDERR]     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

       

      01:18:36,493 ERROR [STDERR]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

       

      01:18:36,493 ERROR [STDERR]     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

       

      01:18:36,493 ERROR [STDERR]     at java.lang.Class.forName0(Native Method)

       

      01:18:36,493 ERROR [STDERR]     at java.lang.Class.forName(Class.java:247)

       

      01:18:36,493 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:284)

       

      01:18:36,493 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1152)

       

      01:18:36,493 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:886)

       

      01:18:36,493 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoader.doLoadClass(BaseClassLoader.java:505)

       

      01:18:36,493 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:450)

       

      01:18:36,493 ERROR [STDERR]     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

       

      01:18:36,493 ERROR [STDERR]     at java.lang.Class.forName0(Native Method)

       

      01:18:36,493 ERROR [STDERR]     at java.lang.Class.forName(Class.java:247)

       

      01:18:36,493 ERROR [STDERR]     at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:603)

       

      01:18:36,493 ERROR [STDERR]     at org.hornetq.utils.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:69)

       

      01:18:36,493 ERROR [STDERR]     at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)

       

      01:18:36,493 ERROR [STDERR]     at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)

       

      01:18:36,493 ERROR [STDERR]     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)

       

      01:18:36,493 ERROR [STDERR]     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

       

      01:18:36,493 ERROR [STDERR]     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)

       

      01:18:36,493 ERROR [STDERR]     at org.hornetq.jms.client.HornetQObjectMessage.getObject(HornetQObjectMessage.java:158)

       

      01:18:36,493 ERROR [STDERR]     at gov.dhs.st.bordernet.services.push.ProxyMessageListener.onMessage(ProxyMessageListener.java:71)

       

      01:18:36,493 ERROR [STDERR]     at org.hornetq.jms.client.JMSMessageListenerWrapper.onMessage(JMSMessageListenerWrapper.java:91)

       

      01:18:36,493 ERROR [STDERR]     at org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:822)

       

      01:18:36,493 ERROR [STDERR]     at org.hornetq.core.client.impl.ClientConsumerImpl.access$100(ClientConsumerImpl.java:46)

       

      01:18:36,493 ERROR [STDERR]     at org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:940)

       

      01:18:36,493 ERROR [STDERR]     at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:100)

       

      01:18:36,493 ERROR [STDERR]     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

       

      01:18:36,493 ERROR [STDERR]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

       

      01:18:36,493 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:662)

       

       

      HornetQ is able to resolve the class of an ObjectMessage when my receiving client is an MDB but not when it is a client MessageListener that I have deployed as part of a JBoss system service.

       

      Following is a representative view of the package structure of my deployment

       

       

      my.ear

      |

      |

      |--------> payload-objects.jar

      |    |

      |    |--------> class(es) used as payload of ObjectMessage located here (and below.)

      |

      |--------> my-ejb.jar

      |    |

      |    |--------> my-service.xml

      |    |

      |    |--------> toplevel

      |    |    |

      |    |    |--------> mdb

      |    |    |     |

      |    |    |     |--------> MDB's located here (and below.)  HornetQ references to classes in payload-objects.jar resolve fine.

      |    |    |

      |    |    |--------> services

      |    |          |

      |    |          |--------> Other MessageListeners located here (and below.) HornetQ references to classes in payload-objects.jar fail!

      |

      |--------> my-war.war

            |

            |--------> WEB-INF

                 |

                 |--------> classes

                 |    |

                 |    |--------> no HornetQ MessageListeners here (or below) but other references to classes in payload-objects.jar here (and below) resolve fine.

                 |

                 |--------> lib

                      |

                      |--------> payload-objects.jar

       

       

      Please advise.

       

       

      Kevin H.

        • 2. HornetQ can't resolve class of ObjectMessage payload.
          kjh21 Newbie

          As suggested, I downloaded the most recent nightly build for AS6 (jboss-6.1.0-SNAPSHOT from 4/8/2011 12:32pm).

           

          Installed the new version and redeployed my app (with no changes) and am now getting the following exception:

           

          19:44:54,625 ERROR [JMSUtil] Caught NamingException looking up initial context:  javax.naming.NameNotFoundException: ConnectionFactory not bound

           

          JMSUtil a support class for my JBoss system service that is trying to setup a MessageListener.  

           

          A call is made to lookup the HornetQ JMS ConnectionFactory but at the time the call is made, no object has been bound to ConnectionFactory in the global JNDI namespace.  I added some debug code to check everything bound at the time of the call and there are no HornetQ related objects there.

           

          This part worked fine under AS 6.0.0 but failed subsequently as described earlier.

           

          Is this a new  dependency-related problem?

           

          How can I make my JBoss system service dependent on the deployment of HornetQ having completed.

           

          I gave that a try by adding the following line to my service configuration file:

           

                  <depends>hornetq:name=JMSProvider,service=JMSProviderLoader</depends>       

           

          but that seems to have had no effect.

           

          Please advise.

           

           

          Kevin H.

          • 3. HornetQ can't resolve class of ObjectMessage payload.
            kjh21 Newbie

            I confirmed that ConnectionFactory not bound error is a dependency problem by starting the app server without my .ear so that HornetQ was fully deployed.  I then dropped in my .ear and it deployed fine.

             

            Unfortunately, I got the same error in JBoss AS 6.1.0 as I described in my original 6.0.0 related post.  That is, HornetQ could not resolve the class of the payload of an ObjectMessage (for a non-MDB client living in the container and deployed as part of a JBoss xxx-service.xml service.)

             

            I'm generally reluctant to assume a problem like this is not attributable to something I'm doing incorrectly.    I'm also not averse to employing outside-the-box resolutions, even if it involves a little secret sauce.

             

            In this case though, I'm left with the impression that JBoss AS 6.0.0/HornetQ is just not ready for prime time.

             

            Kevin H.

            • 4. HornetQ can't resolve class of ObjectMessage payload.
              kjh21 Newbie

              I rolled back to JBoss 6.0.0 to elinate the dependency issue that arose with 6.1.0 and then employoed the work=around suggested here to address the original problem resolving the class of an ObjectMessage payload.

               

              http://community.jboss.org/message/517604#517604

               

              That post involves essentially the same problem encountered by a JBoss 5.1 .0 user

               

              The "fix" (see code below) involves resetting the class loader associated with the context of the thread on which the message is dispatched to the loader associated with the class of the MessageListener.

               

              It works but that is a rather extreme work-around.

               

              This seems like a fundamental and still outstanding problem with JBoss unless it's related to something about the way I've packaged my.ear.

               

              The only things I can add to my earlier characterization of the deployment  are

               

              1) the payload-objects.jar deployed at the root of my.ear file does share (up to a point) the same parent package structure of classes of my -service.xml service deployed in my-ejb.jar.  There are, however, no  classes that appear in both payload-objects.jar and my-ejb.jar.

               

              2) The META-INF/MANIFEST.MF file of  my-ejb.jar  contains the following line

               

              Class-Path: payload-objects.jar

               

               

              Both those seem reasonable and proper.

               

               

               

              public void onMessage(Message recvMsg)
              {

              ObjectMessage om = (ObjectMessage) recvMsg;


              ClassLoader originalTCCL = Thread.currentThread().getContextClassLoader();
              try
              {
                // temporarily change TCCL, just for testing
                Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
                 // now get the message from ObjectMessage
              Object obj =   om.getObject();
              // print out the message for testing
              System.out.println("Obtained message " + obj);
              }
              finally
              {
                // set back the original TCCL
              Thread.currentThread().setContextClassLoader(originalTCCL);
              }
              ...

              • 5. HornetQ can't resolve class of ObjectMessage payload.
                Clebert Suconic Master

                I'm really sure I have fixed this on HQ 2.2. I'm not sure why you're seeing this dependency issue when you moved.

                 

                Someone could take a look if you attach a way to replicate it.

                • 6. Re: HornetQ can't resolve class of ObjectMessage payload.
                  Joshua Davis Expert

                  I'm having the same problem with an application deployed in JBoss AS 7.0.1.Final, as a JEE6 WAR file.   The message object class lives in the WAR along with the producer and consumer.   However, objectMessage.getObject() fails unless I set the TCCL temporarily around the call.   It looks like HornetQ is not using the WAR ClassLoader.

                   

                  JBoss AS Version: JBoss AS 7.0.1.Final

                  HornetQ Version: HornetQ Server version 2.2.7.Final (HQ_2_2_7_FINAL_AS7, 121)

                  • 7. Re: HornetQ can't resolve class of ObjectMessage payload.
                    Jeff Mesnil Master

                    I try to replicate it using a EAR and the code was working as expected without any change to the TCCL in app code: https://github.com/jmesnil/objectmessage-ear