Sorry I found the problem.  My bone headed mistake.  I was putting a String in the 
setObject method instead
of the object.  It works just fine

Steve Wilkinson wrote:

> I'm using JBoss2.2.2_Tomcat3.2.2 binary distribution.  I've created a
> MDB that can receive TextMessages just fine.  I've recently added an
> ObjectMessage and I receive the following error message.
>
> [QueueBean] Transaction rolled back; nested exception is:
> java.lang.ClassCastException: java.lang.String
> [QueueBean] Transaction rolled back; nested exception is:
> java.lang.ClassCastException: java.lang.String
> [Container factory] Exception in JMSCI message listener: :
> java.rmi.ServerException: Transaction rolled back; nested exception is:
> java.lang.ClassCastException: java.lang.String
> [Container factory] java.rmi.ServerException: Transaction rolled back;
> nested exception is:         java.lang.ClassCastException:
> java.lang.String
> [Container factory] java.lang.ClassCastException: java.lang.String
> [Container factory]     at
> test.bean.QueueBean.onMessage(QueueBean.java:75)
> [Container factory]     at java.lang.reflect.Method.invoke(Native
> Method)
> [Container factory] Exception in JMSCI message listener: :
> java.rmi.ServerException: Transaction rolled back; nested exception
> is:        java.lang.ClassCastException: java.lang.String
> [Container factory]     at
> 
>org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:383)
>
> [Container factory]     at
> 
>org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT.invoke(MessageDrivenTxInterceptorBMT.java:83)
>
> [Container factory]     at
> 
>org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:58)
>
> [Container factory]     at
> org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:190)
>
> [Container factory]     at
> org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
> [Container factory]     at
> org.jboss.ejb.MessageDrivenContainer.invoke(MessageDrivenContainer.java:264)
>
> [Container factory]     at
> org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:151)
>
> [Container factory]     at
> 
>org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:448)
>
> [Container factory]     at
> org.jbossmq.SpyMessageConsumer.deliverMessage(SpyMessageConsumer.java:294)
>
> [Container factory]     at
> org.jbossmq.SpySession.run(SpySession.java:236)
> [Container factory]     at
> org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:131)
> [Container factory]     at
> org.jboss.jms.asf.ThreadPool$Worker.run(ThreadPool.java:128)
> [Container factory] java.rmi.ServerException: Transaction rolled back;
> nested exception is:
>         java.lang.ClassCastException: java.lang.String
>
> The object that I'm putting in the message is Serializable.  Here is the
> client code piece that sends the message to the queue.
>       session = getQueueSession();
>       Queue queue = (Queue)context.lookup(dest);
>       QueueSender sender = session.createSender(queue);
>       /*
>       System.out.println("TestQueue: " + dest + " Sending 10 messages
> 1-10");
>       for (int i = 1; i < 11; i++) {
>         TextMessage message = session.createTextMessage();
>         message.setText("Queue Message " + dest + " nr " + i);
>         sender.send(queue, message);
>       }
>       */
>       for (int i = 1; i < 3; i++) {
>         ObjectMessage message = session.createObjectMessage();
>         Request aRequest = getRequest(i);
>         message.setObject("Queue Message " + dest + " nr " +
> aRequest.toString());
>         sender.send(queue, message);
>       }
>
> I've commented out the TextMessages simply to debug.  They still work.
>
> The QueueBean (the MDB) has the following code:
> public class QueueBean implements MessageDrivenBean, MessageListener{
>   private static String cName = "QueueBean";
>   private static String cNameLog = cName + ".";
>   private MessageDrivenContext ctx = null;
>
>   public QueueBean() {
>     System.out.println(cName + " ctor called.");
>   }
>
>   public void setMessageDrivenContext(MessageDrivenContext ctx)
>     throws EJBException {
>     this.ctx = ctx;
>   }
>
>   public void ejbCreate() {
>     System.out.println(cNameLog + "ejbCreate(): called");
>   }
>
>   public void ejbRemove() {
>     ctx=null;
>   }
>
>   public void onMessage(Message message) {
>     try
>     {
>       System.out.println(message.toString());
>       if(message instanceof TextMessage)
>       {
>         TextMessage textMessage = (TextMessage) message;
>         String text = (String) textMessage.getText();
>         System.out.println("onMessage(): got TextMessage text=<" + text
> + ">");
>       }
>       else if(message instanceof ObjectMessage)
>       {
>         ObjectMessage objectMessage = (ObjectMessage) message;
>         Request aRequest = (Request) objectMessage.getObject();
>         System.out.println("onMessage(): got ObjectMessage " +
>                             "aRequest.toString()=<" +
>                             aRequest.toString() + ">");
>       }
>     }
>     catch(JMSException ex)
>     {
>       ex.printStackTrace();
>     }
>   }
> }
>
> The ejb-jar.xml is:
> <ejb-jar>
>   <enterprise-beans>
>     <message-driven>
>       <ejb-name>QueueBean</ejb-name>
>       <ejb-class>test.bean.QueueBean</ejb-class>
>       <message-selector></message-selector>
>       <transaction-type>Bean</transaction-type>
>       <acknowledge-mode>Auto-acknowledge</acknowledge-mode>
>       <message-driven-destination>
>         <destination-type>javax.jms.Queue</destination-type>
>       </message-driven-destination>
>     </message-driven>
>   </enterprise-beans>
> </ejb-jar>
>
> The jboss.xml is:
> <jboss>
>   <enterprise-beans>
>     <message-driven>
>       <ejb-name>QueueBean</ejb-name>
>       <configuration-name>Standard Message Driven
> Bean</configuration-name>
>       <destination-jndi-name>queue/testQueue</destination-jndi-name>
>     </message-driven>
>   </enterprise-beans>
> </jboss>
>
> This there some way to get the ObjectMessage?  Do I need to let the
> Consumer know about the Object?  I have the Serializable class in the
> jar file when I deploy it.
>
> Please help I'm new to MDB.
> Thanks in advance,
> Steve


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to