JMS Consumer can not resolve class of the object passed in ObjectMessage
tony.leaf.1 Mar 17, 2014 2:26 PMi'm using JBoss AS7 and I'm trying to send and receive object trough JMS. Here's my code:
public void onMessage(Message m) { try { ObjectMessage ob=(ObjectMessage) m; Object o= ob.getObject(); System.out.println("siiiii"); //bm.readBytes(b); //BufferedOutputStream bos=new BufferedOutputStream(new BufferedWriter(b)); //Dispositivo d = bm. } catch (JMSException e) { e.printStackTrace(); System.err.println("JMSException in onMessage(): " + e.toString()); } }
and i get these errors:
avax.jms.JMSException: ebiga.procedureoperative.model.Dispositivo from [Module "org.hornetq:main" from local module loader @430ef1aa (roots: D:\Lavoro\jboss-as-7.1.1.Final\modules)]
19:09:41,919 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
19:09:41,922 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
19:09:41,930 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
19:09:41,943 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
19:09:41,950 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
19:09:41,984 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at java.lang.Class.forName0(Native Method)
19:09:41,990 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at java.lang.Class.forName(Unknown Source)
19:09:41,994 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at java.io.ObjectInputStream.resolveClass(Unknown Source)
19:09:41,997 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.hornetq.utils.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:71)
19:09:42,003 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
19:09:42,007 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at java.io.ObjectInputStream.readClassDesc(Unknown Source)
19:09:42,009 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
19:09:42,015 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at java.io.ObjectInputStream.readObject0(Unknown Source)
19:09:42,018 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at java.io.ObjectInputStream.readObject(Unknown Source)
19:09:42,022 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.hornetq.jms.client.HornetQObjectMessage.getObject(HornetQObjectMessage.java:158)
19:09:42,025 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at jms.ConsumerMessageListener.onMessage(ConsumerMessageListener.java:38)
19:09:42,034 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:09:42,037 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
19:09:42,040 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
19:09:42,043 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at java.lang.reflect.Method.invoke(Unknown Source)
19:09:42,046 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)
19:09:42,053 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
19:09:42,056 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
19:09:42,066 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)
19:09:42,071 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
19:09:42,074 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
19:09:42,079 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
19:09:42,082 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
19:09:42,086 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
19:09:42,092 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
19:09:42,095 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
19:09:42,101 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
19:09:42,106 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:202)
19:09:42,110 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:306)
19:09:42,114 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)
19:09:42,121 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
19:09:42,125 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
19:09:42,128 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
19:09:42,131 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
19:09:42,135 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
19:09:42,138 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
19:09:42,142 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
19:09:42,146 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:43)
19:09:42,168 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
19:09:42,171 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription$5$1.processInvocation(MessageDrivenComponentDescription.java:184)
19:09:42,176 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
19:09:42,197 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
19:09:42,202 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
19:09:42,206 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
19:09:42,210 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
19:09:42,213 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173)
19:09:42,217 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
19:09:42,220 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
19:09:42,223 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)
19:09:42,226 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at javax.jms.MessageListener$$$view19.onMessage(Unknown Source)
19:09:42,229 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:09:42,232 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
19:09:42,235 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
19:09:42,237 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at java.lang.reflect.Method.invoke(Unknown Source)
19:09:42,240 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ejb3.inflow.MessageEndpointInvocationHandler.doInvoke(MessageEndpointInvocationHandler.java:140)
19:09:42,244 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.jboss.as.ejb3.inflow.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:73)
19:09:42,247 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at com.sun.proxy.$Proxy51.onMessage(Unknown Source)
19:09:42,250 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.hornetq.ra.inflow.HornetQMessageHandler.onMessage(HornetQMessageHandler.java:278)
19:09:42,252 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:983)
19:09:42,255 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.hornetq.core.client.impl.ClientConsumerImpl.access$400(ClientConsumerImpl.java:48)
19:09:42,257 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:1113)
19:09:42,259 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:100)
19:09:42,262 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
19:09:42,265 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
19:09:42,268 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) at java.lang.Thread.run(Unknown Source)
19:09:42,269 ERROR [stderr] (Thread-15 (HornetQ-client-global-threads-202023893)) JMSException in onMessage(): javax.jms.JMSException: ebiga.procedureoperative.model.Dispositivo from [Module "org.hornetq:main" from local module loader @430ef1aa (roots: D:\Lavoro\jboss-as-7.1.1.Final\modules)]
Seems that ObjectInputStream takes the classloader of the calling method. I don't kno w how to fix this problems. Can anyone help me? Thanks