Its IMHO better to not use Java Objects with JMS. Otherwise you need to make sure the same classes are on the classpath on both the clients and servers, and that they are compatible.
Instead you can tell Camel to use javax.jms.TextMessage as your POJO is a JAXB annotated that can be marshalled into XML. You can use the jmsMessageType option. See more details at http://camel.apache.org/jms <from uri="activemq:OBJECT.QUEUE2" /> <to uri="activemq:OBJECT.QUEUE3?jmsMessageType=Text" /> On Thu, Jan 16, 2014 at 7:05 AM, contactreji <contactr...@gmail.com> wrote: > Hi > I am trying to move contents of one queue to another queue. > > The source queue contains Java object. > > My came route is as follows > * > <?xml version="1.0" encoding="UTF-8"?> > > > <beans xmlns="http://www.springframework.org/schema/beans" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:amq="http://activemq.apache.org/schema/core" > xsi:schemaLocation=" > http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans.xsd > http://camel.apache.org/schema/spring > http://camel.apache.org/schema/spring/camel-spring.xsd > http://activemq.apache.org/schema/core > http://activemq.apache.org/schema/core/activemq-core.xsd"> > > > <bean id="activemq" > class="org.apache.activemq.camel.component.ActiveMQComponent"> > <property name="brokerURL" > value="failover:tcp://localhost:61620" /> > <property name="userName" value="admin" /> > <property name="password" value="admin" /> > </bean> > > > <camelContext xmlns="http://camel.apache.org/schema/spring"> > <route> > <from uri="activemq:OBJECT.QUEUE2" /> > <to uri="activemq:OBJECT.QUEUE3" /> > </route> > </camelContext> > > </beans>* > > > It OBJECT.QUEUE1 contains an object of class Student. > > > * > Student.java Class > ------------- > > package com.queueshifter.camel.activemq.queueshifter; > > import java.io.Serializable; > > import javax.xml.bind.annotation.XmlAccessorType; > import javax.xml.bind.annotation.XmlAttribute; > import javax.xml.bind.annotation.XmlElement; > import javax.xml.bind.annotation.XmlRootElement; > > > @XmlAccessorType > @XmlRootElement > public class Student implements Serializable{ > > //@XmlElement > String name; > > //@XmlElement > int rollNo; > public String getName() { > return name; > } > public void setName(String name) { > this.name = name; > } > public int getRollNo() { > return rollNo; > } > public void setRollNo(int rollNo) { > this.rollNo = rollNo; > } > > } > > * > > > I get following error while running the routes. > > Any ideas will be very helpful > > Cheers > Reji > > > * > [0 - JmsConsumer[OBJECT.QUEUE2]] EndpointMessageListener WARN > Execution of JMS message listener failed. Caused by: > [org.apache.camel.RuntimeCamelException - Failed to extract body due to: > javax.jms.JMSException: Failed to build body from content. Serializable > class not available to broker. Reason: java.lang.ClassNotFoundException: > com.poc.camel.jaxb.Student. Message: ActiveMQObjectMessage {commandId = 7, > responseRequired = true, messageId = > ID:D-113043114-56208-1389845707678-3:1:1:1:3, originalDestination = > queue://OBJECT.QUEUE, originalTransactionId = null, producerId = > ID:D-113043114-56208-1389845707678-3:1:1:1, destination = > queue://OBJECT.QUEUE2, transactionId = null, expiration = 0, timestamp = > 1389845710753, arrival = 0, brokerInTime = 1389851883384, brokerOutTime = > 1389851883384, correlationId = null, replyTo = null, persistent = true, type > = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = > null, compressed = false, userID = null, content = > org.apache.activemq.util.ByteSequence@12cd7ba, marshalledProperties = > org.apache.activemq.util.ByteSequence@106fe2b, dataStructure = null, > redeliveryCounter = 0, size = 0, properties = {firedTime=Thu Jan 16 09:45:09 > IST 2014, breadcrumbId=ID-D-113043114-56207-1389845706616-0-1, > CamelJmsDeliveryMode=2}, readOnlyProperties = true, readOnlyBody = true, > droppable = false}] > org.apache.camel.RuntimeCamelException: Failed to extract body due to: > javax.jms.JMSException: Failed to build body from content. Serializable > class not available to broker. Reason: java.lang.ClassNotFoundException: > com.poc.camel.jaxb.Student. Message: ActiveMQObjectMessage {commandId = 7, > responseRequired = true, messageId = > ID:D-113043114-56208-1389845707678-3:1:1:1:3, originalDestination = > queue://OBJECT.QUEUE, originalTransactionId = null, producerId = > ID:D-113043114-56208-1389845707678-3:1:1:1, destination = > queue://OBJECT.QUEUE2, transactionId = null, expiration = 0, timestamp = > 1389845710753, arrival = 0, brokerInTime = 1389851883384, brokerOutTime = > 1389851883384, correlationId = null, replyTo = null, persistent = true, type > = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = > null, compressed = false, userID = null, content = > org.apache.activemq.util.ByteSequence@12cd7ba, marshalledProperties = > org.apache.activemq.util.ByteSequence@106fe2b, dataStructure = null, > redeliveryCounter = 0, size = 0, properties = {firedTime=Thu Jan 16 09:45:09 > IST 2014, breadcrumbId=ID-D-113043114-56207-1389845706616-0-1, > CamelJmsDeliveryMode=2}, readOnlyProperties = true, readOnlyBody = true, > droppable = false} > at > org.apache.camel.component.jms.JmsBinding.extractBodyFromJms(JmsBinding.java:150)[camel-jms-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.component.jms.JmsMessage.createBody(JmsMessage.java:214)[camel-jms-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:41)[camel-core-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.impl.DefaultUnitOfWork.<init>(DefaultUnitOfWork.java:88)[camel-core-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.impl.DefaultUnitOfWork.<init>(DefaultUnitOfWork.java:71)[camel-core-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.processor.UnitOfWorkProcessor.createUnitOfWork(UnitOfWorkProcessor.java:190)[camel-core-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)[camel-core-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)[camel-core-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)[camel-core-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)[camel-core-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)[camel-core-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:104)[camel-jms-2.10.0.fuse-71-047.jar:2.10.0.fuse-71-047] > at > org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:560)[spring-jms-3.0.7.RELEASE.jar:3.0.7.RELEASE] > at > org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:498)[spring-jms-3.0.7.RELEASE.jar:3.0.7.RELEASE] > at > org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467)[spring-jms-3.0.7.RELEASE.jar:3.0.7.RELEASE] > at > org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)[spring-jms-3.0.7.RELEASE.jar:3.0.7.RELEASE] > at > org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)[spring-jms-3.0.7.RELEASE.jar:3.0.7.RELEASE] > at > org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1058)[spring-jms-3.0.7.RELEASE.jar:3.0.7.RELEASE] > at > org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1050)[spring-jms-3.0.7.RELEASE.jar:3.0.7.RELEASE] > at > org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:947)[spring-jms-3.0.7.RELEASE.jar:3.0.7.RELEASE] > at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown > Source)[:1.7.0_45] > at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown > Source)[:1.7.0_45] > at java.lang.Thread.run(Unknown Source)[:1.7.0_45] > * > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Moving-Objects-between-Active-MQ-queues-using-Camel-Routes-tp5746020.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen Make your Camel applications look hawt, try: http://hawt.io