5 Replies Latest reply on Apr 22, 2013 7:18 AM by newway

    getting JMSException when casting the object message to custom object class

    a4arjun

      Hi all,

       

      i am using one client which will send message to jms queue.

      The message is of type ObjectMessage.

      I am sending a object of class SampleBean(a bean class with getters and setters implements Serializable )

      the client is one application.

       

      then another application(consumer) which has MDB and in onMessage i used

       

      SampleBean sampleBean = (SampleBean) ((ObjectMessage) message).getObject();

       

      while running i am getting JMSException

       

      MDBjavax.jms.JMSException: com.jms.test.SampleBean from [Module "org.hornetq:main" from local module loader @1f4899c (roots: JBOSS_HOME\modules)]

       

       

      i use JBOSS AS 7.1.1 final

      i configured the queue in standalone-full.xml

       

       

      please help.

       

       

      Thanks in advance.

        • 1. Re: getting JMSException when casting the object message to custom object class
          newway

          Can you give a little more of the exception stack trace?

           

          I don't understand the context of the error and what the exception is saying

           

          Noa

          • 2. Re: getting JMSException when casting the object message to custom object class
            a4arjun

            exception stack trace

             

            org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

            org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

            org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

            org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

            org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

            java.lang.Class.forName0(Native Method)

            java.lang.Class.forName(Class.java:264)

            java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:622)

            org.hornetq.utils.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:71)

            java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1593)

            java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1514)

            java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)

            java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)

            java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)

            org.hornetq.jms.client.HornetQObjectMessage.getObject(HornetQObjectMessage.java:158)

            com.unwire.platforms.fts.routing.consumer.MessageConsumer.onMessage(MessageConsumer.java:64)

            sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

            sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

            sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

            java.lang.reflect.Method.invoke(Method.java:601)

            org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374)

            org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:127)

            org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:135)

            org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

            org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:101)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

            org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:202)

            org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:306)

            org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:43)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription$5$1.processInvocation(MessageDrivenComponentDescription.java:184)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

            org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)

            org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173)

            org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

            org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

            org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)

            javax.jms.MessageListener$$$view11.onMessage(Unknown Source)

            sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

            sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

            sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

            java.lang.reflect.Method.invoke(Method.java:601)

            org.jboss.as.ejb3.inflow.MessageEndpointInvocationHandler.doInvoke(MessageEndpointInvocationHandler.java:140)

            org.jboss.as.ejb3.inflow.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:73)

            $Proxy73.onMessage(Unknown Source)

            org.hornetq.ra.inflow.HornetQMessageHandler.onMessage(HornetQMessageHandler.java:278)

            org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:983)

            org.hornetq.core.client.impl.ClientConsumerImpl.access$400(ClientConsumerImpl.java:48)

            org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:1113)

            org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:100)

            java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

            java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

            java.lang.Thread.run(Thread.java:722)

            • 3. Re: getting JMSException when casting the object message to custom object class
              newway

              Hi,

               

              when giving a stack trace I would usually expect to get it like:

               

              some exception info -

              caused by

              and than the stack trace

               

              when you give fragmented info it is hard to help.

               

              putting that aside:

               

              where is - SampleBean defined? it looks like the class is not available for the MDB and maybe the JMS exception is just catching a class cast exception?

               

              Regards,

              Noa

              • 4. Re: getting JMSException when casting the object message to custom object class
                a4arjun

                jmsclient and consumer are 2 different project running in same jboss server.

                 

                i defined the SampleBean in both the project.

                 

                the stacktrace what i given is e.printStackTrace()

                 

                how will i make the class available to MDB?. Now i have deifned the same SampleBean in both client and consumer.

                • 5. Re: getting JMSException when casting the object message to custom object class
                  newway

                  I think that it's more of a question to the AS forum and not for hornetq.

                   

                  basically if the client and the consumer are not part of the same app(=EAR) and SampleBean is not part of the projects you can:

                  1. package the jar that defines the bean with both of them

                  2. you can add the jar where SampleBean is defined as a module in jboss and make sure the client and the consumer are using this module

                   

                  you can read about modules in the jboss AS documentation and there are many questions around this area in the AS forums

                   

                  Regards,

                  Noa

                  1 of 1 people found this helpful