1 Reply Latest reply on Dec 25, 2009 9:28 AM by jaikiran pai

    JMS Consumer (servlet) can not resolve class of the object passed in ObjectMessage (AS 5.1.0)

    Alexander Lengson Newbie

      Hello All,

       

      Please help me to recognize my trouble with messaging in JBoss 5.1.0:

       

      My message's consumer class extends MessageListener.

      The single object of consumer is created in servlet's init() method.

       

      Servlet is part of WAR which is packaged inside EAR module.

      There is jar module which share common classes for WAR and other EJBs in EAR.

       

      One of EJB sends JMS message ObjectMessage to some topic which is monitored by the servlet's consumer.

      Payload of ObjectMessage is one of common shared classes.

       

      The servlet's consumer can not resolve the class of the object passed in ObjectMessage and fails at line:

       

      public void onMessage(Message recvmsg) {

          ObjectMessage om = (ObjectMessage) recvmsg;


          Class classOrder = Class.forName("com.name.shared.Order"); // ok!

          om.getObject(); // here fails!

       

      I've noticed that classloaders of the recvmsg and classOrder are different:

      INFO  [EventListenerServlet] BaseClassLoader@1a7249f{vfsfile:/C:/jboss/jboss-5.1.0.GA/server/standard/deploy/ecom.ear/}

      INFO  [EventListenerServlet] BaseClassLoader@fb111c{vfsfile:/C:/jboss/jboss-5.1.0.GA/server/standard/conf/jboss-service.xml}

      Is that exception due to the difference between class loaders actually?

       

      The strange point is that the code works from time to time (in the case of rare messages, for example). When messages go quickly, it starts throwing exceptions.

       

      JBoss AS 5.0.1 serves all incoming messages well even in the case of high load.

       

      I've asked that question in "JBoss Messaging" already (http://community.jboss.org/message/517783#517783), and Yong Hao Gao advised me to repeat it in AS forum. Upgrading jboss messaging from 1.4.3.GA to 1.4.6.GA did not resolve the trouble.

       

      Stack trace:

       

      ERROR [ClientConsumer] RuntimeException was thrown from onMessage, 20669661515808833 will be redelivered

      java.lang.RuntimeException: com.name.shared.Order

      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

      at java.security.AccessController.doPrivileged(Native Method)

      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

      at java.lang.ClassLoader.loadClass(ClassLoader.java:252)

      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

      at java.lang.Class.forName0(Native Method)

      at java.lang.Class.forName(Class.java:247)

      at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:292)

      at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1119)

      at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:798)

      at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:441)

      at java.lang.ClassLoader.loadClass(ClassLoader.java:252)

      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

      at java.lang.Class.forName0(Native Method)

      at java.lang.Class.forName(Class.java:247)

      at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604)

      at org.jboss.messaging.util.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:78)

      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)

      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)

      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)

      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)

      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)

      at org.jboss.messaging.util.StreamUtils.readObject(StreamUtils.java:154)

      at org.jboss.messaging.core.impl.message.MessageSupport.readPayload(MessageSupport.java:392)

      at org.jboss.jms.message.JBossObjectMessage.getObject(JBossObjectMessage.java:126)

      at org.jboss.jms.message.ObjectMessageProxy.getObject(ObjectMessageProxy.java:68)

      at com.name.servlet.EventListenerServlet$EventListener.onMessage(EventListenerServlet.java:201)

      at org.jboss.jms.client.container.ClientConsumer.callOnMessage(ClientConsumer.java:229)

      at org.jboss.jms.client.container.ClientConsumer$ListenerRunner.run(ClientConsumer.java:1043)

      at org.jboss.messaging.util.OrderedExecutorFactory$ChildExecutor.run(OrderedExecutorFactory.java:120)

      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

      at java.lang.Thread.run(Thread.java:619)