7 Replies Latest reply on Jan 6, 2011 1:48 PM by ekomlan

    objectMessage.getObject() throwing JMSException in MDB

    bprjboss
      Hi ,
      I am just trying a simple example where I want to consume a serialized object in a MDB.
      I am using jboss 6.0 CR1.
      JMSException error code is null.
      Here is my code
      code for the MDB class
      @MessageDriven(    name = "MDBMessageSendTxExample",               activationConfig = {@MessageDriven(name = "ProcessMessageMDB",               activationConfig = {                       @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/BPRqueue"),                       @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")                       }             )public class ProcessMessageMDB implements MessageListener {   /**    * Default constructor.    */   public ProcessMessageMDB() {       // TODO Auto-generated constructor stub  }   /**    * @see MessageListener#onMessage(Message)    */  public void onMessage(Message message) {       try      {   if(message instanceof ObjectMessage)            {         ObjectMessage objectMessage=(ObjectMessage)message;                  BPRtest bprt=(BPRtest)objectMessage.getObject();          }       }       catch(Exception e)       {           System.out.println("In catch block");           e.printStackTrace();      }   }
      @MessageDriven(    name = "ProcessMessageMDB",
                     activationConfig = {
      @MessageDriven(name = "ProcessMessageMDB",
                     activationConfig = {
                             @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/BPRqueue"),
                             @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
                             }
                   )
      public class ProcessMessageMDB implements MessageListener {
         /**
          * Default constructor.
          */
         public ProcessMessageMDB() {
             // TODO Auto-generated constructor stub
        }
         /**
          * @see MessageListener#onMessage(Message)
          */
        public void onMessage(Message message) {
             try
            {
         if(message instanceof ObjectMessage)
                  {
               ObjectMessage objectMessage=(ObjectMessage)message;
                        BPRtest bprt=(BPRtest)objectMessage.getObject();   //In this line I am getting JMSException
                }
             }
             catch(JMSException e)
             {
                 System.out.println("In catch block");
                 e.printStackTrace();
            }
         }
      The client code:
      Session session =null;
      Connection connection=null;
             try {
      TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName());
                  ConnectionFactory connectionFactory = HornetQJMSClient.createConnectionFactory(transportConfiguration);
                  Queue bprQueue = HornetQJMSClient.createQueue("BPRqueue");
                 connection = connectionFactory.createConnection();
                 session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                 MessageProducer producer = session.createProducer(bprQueue);
                connection.start();
                  ObjectMessage objectMessage =  session.createObjectMessage();
                  BPRtest bprt= new BPRtest(234,"xyz");
                  objectMessage.setObject(bprt);
                   producer.send(objectMessage);
                  System.out.println("Sent object to queue"+ bprt.toString());
            }
             catch (JMSException e) {
                 System.out.println("JMSException caught here");
                 e.printStackTrace();
             }
             catch(Exception e)
             {
                 System.out.println("Exception caught here");
                 e.printStackTrace();
             }
             finally
             {
                 try {
                     session.close();
                     connection.close();
                 } catch (JMSException e) {
                     // TODO Auto-generated catch block
                    e.printStackTrace();
                 }
             }

      Hi ,

       

      I am just trying to consume a serialized object in a MDB.

      I am using JBoss6.0 CR1.

      Here is my code

       

      code for the MDB class

       

      @MessageDriven(name = "ProcessMessageMDB",

                     activationConfig = {

                             @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/BPRqueue"),

                             @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")

                             }

                   )

      public class ProcessMessageMDB implements MessageListener {

       

         /**

          * Default constructor.

          */

         public ProcessMessageMDB() {

             // TODO Auto-generated constructor stub

        }

       

         /**

          * @see MessageListener#onMessage(Message)

          */

        public void onMessage(Message message) {

       

             try

            {

          if(message instanceof ObjectMessage)

                  {

                ObjectMessage objectMessage=(ObjectMessage)message;

                        BPRtest bprt=(BPRtest)objectMessage.getObject();   //In this line I am getting JMSException

                }

             }

             catch(JMSException e)

             {

                 System.out.println("In catch block");

                 e.printStackTrace();

            }

         }

       

       

       

       

      The client code:

       

       

      Session session =null;

      Connection connection=null;

       

             try {

      TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName());

                  ConnectionFactory connectionFactory = HornetQJMSClient.createConnectionFactory(transportConfiguration);

                  Queue bprQueue = HornetQJMSClient.createQueue("BPRqueue");

       

                 connection = connectionFactory.createConnection();

                 session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

                 MessageProducer producer = session.createProducer(bprQueue);

                connection.start();

                  ObjectMessage objectMessage =  session.createObjectMessage();

                  BPRtest bprt= new BPRtest(234,"xyz");

                  objectMessage.setObject(bprt);

                   producer.send(objectMessage);

                  System.out.println("Sent object to queue"+ bprt.toString());

       

            }

             catch (JMSException e) {

                 System.out.println("JMSException caught here");

                 e.printStackTrace();

             }

             catch(Exception e)

             {

                 System.out.println("Exception caught here");

                 e.printStackTrace();

             }

             finally

             {

                 try {

                     session.close();

                     connection.close();

                 } catch (JMSException e) {

                     // TODO Auto-generated catch block

                    e.printStackTrace();

                 }

             }

       

       

       

      JMSException that I am getting does not have any additional information.

      The error code of the exception is null.

      Let me know If I am doing anything wrong.

       

      The client which send the message to the queue is actually a Webservice running on the same Jboss server.

      The initial part of the log are from it.

       

       

      The Exception Details

       

      16:42:58,752 INFO  [com.apple.bpms.webservice.EventManagementServices] ENTERING WEBSERVICE-EVENTMANAGEMENTSERVICES.triggerEP()FOR APPID=123,PRSID=454545

      16:42:58,758 INFO  [STDOUT] Sent object to queueBPRtest [age=123, name=xyz]

      16:42:58,763 INFO  [STDOUT] JMSException caught here

      16:42:58,763 ERROR [STDERR] javax.jms.JMSException: com.apple.bpms.webservice.BPRtest

      16:42:58,764 ERROR [STDERR]     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

      16:42:58,764 ERROR [STDERR]     at java.security.AccessController.doPrivileged(Native Method)

      16:42:58,764 ERROR [STDERR]     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

      16:42:58,764 ERROR [STDERR]     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

      16:42:58,764 ERROR [STDERR]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

      16:42:58,764 ERROR [STDERR]     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

      16:42:58,765 ERROR [STDERR]     at java.lang.Class.forName0(Native Method)

      16:42:58,765 ERROR [STDERR]     at java.lang.Class.forName(Class.java:247)

      16:42:58,765 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:284)

      16:42:58,766 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1152)

      16:42:58,766 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:886)

      16:42:58,766 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoader.doLoadClass(BaseClassLoader.java:505)

      16:42:58,766 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:450)

      16:42:58,766 ERROR [STDERR]     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

      16:42:58,766 ERROR [STDERR]     at java.lang.Class.forName0(Native Method)

      16:42:58,766 ERROR [STDERR]     at java.lang.Class.forName(Class.java:247)

      16:42:58,766 ERROR [STDERR]     at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:603)

      16:42:58,766 ERROR [STDERR]     at org.hornetq.utils.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:69)

      16:42:58,766 ERROR [STDERR]     at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)

      16:42:58,766 ERROR [STDERR]     at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)

      16:42:58,766 ERROR [STDERR]     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)

      16:42:58,766 ERROR [STDERR]     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

      16:42:58,766 ERROR [STDERR]     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)

      16:42:58,766 ERROR [STDERR]     at org.hornetq.jms.client.HornetQObjectMessage.getObject(HornetQObjectMessage.java:158)

      16:42:58,766 ERROR [STDERR]     at com.apple.test.ProcessMessageMDB.onMessage(ProcessMessageMDB.java:62)

      16:42:58,766 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      16:42:58,766 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      16:42:58,766 ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      16:42:58,766 ERROR [STDERR]     at java.lang.reflect.Method.invoke(Method.java:597)

      16:42:58,766 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)

      16:42:58,766 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)

      16:42:58,766 ERROR [STDERR]     at org.jboss.ejb3.interceptors.container.ContainerMethodInvocationWrapper.invokeNext(ContainerMethodInvocationWrapper.java:72)

      16:42:58,766 ERROR [STDERR]     at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:76)

      16:42:58,768 ERROR [STDERR]     at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:62)

      16:42:58,768 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      16:42:58,768 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      16:42:58,768 ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      16:42:58,768 ERROR [STDERR]     at java.lang.reflect.Method.invoke(Method.java:597)

      16:42:58,768 ERROR [STDERR]     at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)

      16:42:58,768 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,768 ERROR [STDERR]     at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)

      16:42:58,768 ERROR [STDERR]     at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_881133949.invoke(InvocationContextInterceptor_z_fillMethod_881133949.java)

      16:42:58,768 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,768 ERROR [STDERR]     at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)

      16:42:58,768 ERROR [STDERR]     at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_881133949.invoke(InvocationContextInterceptor_z_setup_881133949.java)

      16:42:58,768 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,768 ERROR [STDERR]     at org.jboss.ejb3.async.impl.interceptor.FutureSerializingInterceptor.invoke(FutureSerializingInterceptor.java:88)

      16:42:58,768 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,768 ERROR [STDERR]     at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62)

      16:42:58,768 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,768 ERROR [STDERR]     at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)

      16:42:58,768 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,768 ERROR [STDERR]     at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)

      16:42:58,768 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,768 ERROR [STDERR]     at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)

      16:42:58,768 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,769 ERROR [STDERR]     at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:68)

      16:42:58,769 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,769 ERROR [STDERR]     at org.jboss.ejb3.core.context.InvocationContextAdapter.proceed(InvocationContextAdapter.java:70)

      16:42:58,769 ERROR [STDERR]     at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:223)

      16:42:58,769 ERROR [STDERR]     at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:353)

      16:42:58,769 ERROR [STDERR]     at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:209)

      16:42:58,769 ERROR [STDERR]     at org.jboss.ejb3.tx2.aop.CMTTxInterceptorWrapper.invoke(CMTTxInterceptorWrapper.java:52)

      16:42:58,769 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,769 ERROR [STDERR]     at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)

      16:42:58,769 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,769 ERROR [STDERR]     at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:79)

      16:42:58,769 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,769 ERROR [STDERR]     at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)

      16:42:58,769 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,769 ERROR [STDERR]     at org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor.invoke(CurrentInvocationContextInterceptor.java:47)

      16:42:58,769 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,769 ERROR [STDERR]     at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)

      16:42:58,769 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,769 ERROR [STDERR]     at org.jboss.ejb3.interceptor.EJB3TCCLInterceptor.invoke(EJB3TCCLInterceptor.java:86)

      16:42:58,769 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      16:42:58,769 ERROR [STDERR]     at org.jboss.ejb3.mdb.MessagingContainer.localInvoke(MessagingContainer.java:280)

      16:42:58,769 ERROR [STDERR]     at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:299)

      16:42:58,769 ERROR [STDERR]     at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:152)

      16:42:58,769 ERROR [STDERR]     at $Proxy142.onMessage(Unknown Source)

      16:42:58,769 ERROR [STDERR]     at org.hornetq.ra.inflow.HornetQMessageHandler.onMessage(HornetQMessageHandler.java:256)

      16:42:58,769 ERROR [STDERR]     at org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:822)

      16:42:58,769 ERROR [STDERR]     at org.hornetq.core.client.impl.ClientConsumerImpl.access$100(ClientConsumerImpl.java:46)

      16:42:58,770 ERROR [STDERR]     at org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:940)

      16:42:58,770 ERROR [STDERR]     at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:100)

      16:42:58,770 ERROR [STDERR]     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

      16:42:58,770 ERROR [STDERR]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

      16:42:58,770 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:680)

      16:42:58,771 INFO  [com.apple.bpms.webservice.EventManagementServices] PERFORMANCE CHECK FOR WEBSERVICE-EVENTMANAGEMENTSERVICES.triggerEP()-FOR APPID=123,PRSID=454545-Time Taken is19msecs

      16:42:58,771 INFO  [com.apple.bpms.webservice.EventManagementServices] EXITING WEBSERVICE-EVENTMANAGEMENTSERVICES.triggerEP()FOR APPID=123,PRSID=454545

       

       

       

      BPRTest class

       


      public class BPRtest implements Serializable{

       

         
              private int age;
              private String name;
              public int getAge() {
                  return age;
              }
              @Override
              public String toString() {
                  return "BPRtest [age=" + age + ", name=" + name + "]";
              }
              public void setAge(int age) {
                  this.age = age;
              }
              public String getName() {
                  return name;
              }
              public void setName(String name) {
                  this.name = name;
              }
              public BPRtest(int age, String name) {
                  super();
                  this.age = age;
                  this.name = name;
              }
              public BPRtest() {
                  super();
                  // TODO Auto-generated constructor stub
              }
             
      }

       

       

       

      Bishnu