JBoss Community

Re: JMS module (HornetQ) can't find my class from WAR

created by Daniel Bevenius in JBoss AS7 Development - View the full discussion

Hi,

 

I'm not sure I've got the full picture of your application. Does your applications consist on a single war, that is it is both producing messages and consuming messages?

 

I've seen a similar issue but in my case I had an ear, consisting of a war and an ejb. The war posted a ObjectMessage to a queue that an MDB, located in the ejb, listened to. The Object being posted was located in the war.

 

When the MDB called objMessage.getObject() I got the following exception:

 

08:16:27,282 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844)) javax.jms.JMSException: se.rl.domain.User from [Module "org.hornetq:main" from local module loader @508aeb74 (roots: /work/jboss/as/as7/jboss-as/build/target/jboss-as-7.1.0.Alpha2-SNAPSHOT/modules)]
08:16:27,282 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
08:16:27,283 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:485)
08:16:27,283 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:444)
08:16:27,283 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:421)
08:16:27,284 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:143)
08:16:27,284 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at java.lang.Class.forName0(Native Method)
08:16:27,284 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at java.lang.Class.forName(Class.java:247)
08:16:27,285 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:603)
08:16:27,285 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at org.hornetq.utils.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:71)
08:16:27,286 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)
08:16:27,286 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
08:16:27,286 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
08:16:27,286 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
08:16:27,287 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
08:16:27,287 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at org.hornetq.jms.client.HornetQObjectMessage.getObject(HornetQObjectMessage.java:158)
08:16:27,288 ERROR [stderr] (Thread-5 (group:HornetQ-client-global-threads-2068899844))         at se.rl.migrate.mdb.GreeterMDB.onMessage(GreeterMDB.java:42)

 

In my case, I was getting this because when trying to locate the class the ThreadContext classloader is first used. The ThreadContext classloader of the mdb module does not have any knowledge of classes in the war, so the code will fallback and try using the 'org.hornetq:main' module and then throw the error displayed above.

 

I was able to add an explicit dependency from my ejb to my war by adding a manifest header to the ejbs manifest.mf:

 

Dependencies: deployment.earName.ear.warName.war

This is only for testing and I'd probably extract the objects into a separate jar and add them to the lib directory of the ear.

 

Not sure if this helps you at all but thought I'd post it just in case.

 

Regards,

 

/Daniel

Reply to this message by going to Community

Start a new discussion in JBoss AS7 Development at Community