JMS Consumer (servlet) can not resolve class of the object passed in ObjectMessage
sanches Dec 23, 2009 9:53 AMHello 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}
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.
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)