java.io.NotSerializableException with JAXB (unmarshal) + ActiveMQ

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

java.io.NotSerializableException with JAXB (unmarshal) + ActiveMQ

Charles Moulliard
Hi,

When I unmarshall a xml file using Jaxb and that I send the result to an ActiveMq queue, I recive the following error :

1) Error

GRAVE: Failed delivery for exchangeId: ID-dell-charles/1108-1214228785562/0-2. On delivery attempt: 0 caught: java.lang.RuntimeException: com.company.soft.type.schema.Document
java.lang.RuntimeException: com.company.soft.type.schema.Document
        at org.apache.activemq.command.ActiveMQObjectMessage.storeContent(ActiveMQObjectMessage.java:104)
        at org.apache.activemq.command.ActiveMQObjectMessage.setObject(ActiveMQObjectMessage.java:155)
        at org.apache.activemq.ActiveMQSession.createObjectMessage(ActiveMQSession.java:317)
        at org.apache.activemq.pool.PooledSession.createObjectMessage(PooledSession.java:149)
        at org.apache.camel.component.jms.JmsBinding.createJmsMessage(JmsBinding.java:221)
        at org.apache.camel.component.jms.JmsBinding.makeJmsMessage(JmsBinding.java:136)
        at org.apache.camel.component.jms.JmsProducer$2.createMessage(JmsProducer.java:229)
        at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:557)
        at org.springframework.jms.core.JmsTemplate$4.doInJms(JmsTemplate.java:538)
        at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:459)
        at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:535)
        at org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:227)
        at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:61)
        at org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:50)
        at org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:45)
        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:43)
        at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:43)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:57)
        at org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:50)
        at org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:45)
        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:43)
        at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:43)
        at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
        at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
        at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
        at org.apache.camel.component.file.FileConsumer.pollFile(FileConsumer.java:128)
        at org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(FileConsumer.java:77)
        at org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(FileConsumer.java:84)
        at org.apache.camel.component.file.FileConsumer.poll(FileConsumer.java:57)
        at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:65)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
        at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:280)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:135)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:65)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:142)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:166)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
        at java.lang.Thread.run(Thread.java:595)
Caused by: java.io.NotSerializableException: com.company.soft.type.schema.Document
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
        at org.apache.activemq.command.ActiveMQObjectMessage.storeContent(ActiveMQObjectMessage.java:98)

2) Config

        public void configure() {

                DataFormat jaxb = new JaxbDataFormat(
                                "com.company.soft.type.schema");

                errorHandler(deadLetterChannel("seda:errors").maximumRedeliveries(1)
                                .useExponentialBackOff());
                from(
                                "file:///c:/temp/test?moveNamePrefix=c:/temp/consumed/&moveNamePostfix=old")
                                .unmarshal(jaxb)
                                .to("activemq:queue:component.queue");
                               
                               
                               
       <camelContext useJmx="true"
              xmlns="http://activemq.apache.org/camel/schema/spring">               
      <package>com.company.soft.core.routing</package>
          </camelContext> 
         
         
          <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="brokerURL" value="vm://localhost:61616?broker.persistent=false"/>
      </bean>

3) Version used : apache - Camel 1.4 SNAPSHOT, ActiveMQ - 5.1

What is the root cause of this error ?

Regards,

charles
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: java.io.NotSerializableException with JAXB (unmarshal) + ActiveMQ

Charles Moulliard
I think that the error is related to the fact that the java objects (generated by JAXB) must be serialisable before to be send to the ActiveMq queue manager. Unfortunately, the class generated using xjc from the schema are not serialized. How can I disable this when I use "VM" protocol" ? I have try to use the property objectMessageSerilizedDefered = true without success ???


cmoulliard wrote
Hi,

When I unmarshall a xml file using Jaxb and that I send the result to an ActiveMq queue, I recive the following error :

1) Error

GRAVE: Failed delivery for exchangeId: ID-dell-charles/1108-1214228785562/0-2. On delivery attempt: 0 caught: java.lang.RuntimeException: com.company.soft.type.schema.Document
java.lang.RuntimeException: com.company.soft.type.schema.Document
        at org.apache.activemq.command.ActiveMQObjectMessage.storeContent(ActiveMQObjectMessage.java:104)
        at org.apache.activemq.command.ActiveMQObjectMessage.setObject(ActiveMQObjectMessage.java:155)
        at org.apache.activemq.ActiveMQSession.createObjectMessage(ActiveMQSession.java:317)
        at org.apache.activemq.pool.PooledSession.createObjectMessage(PooledSession.java:149)
        at org.apache.camel.component.jms.JmsBinding.createJmsMessage(JmsBinding.java:221)
        at org.apache.camel.component.jms.JmsBinding.makeJmsMessage(JmsBinding.java:136)
        at org.apache.camel.component.jms.JmsProducer$2.createMessage(JmsProducer.java:229)
        at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:557)
        at org.springframework.jms.core.JmsTemplate$4.doInJms(JmsTemplate.java:538)
        at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:459)
        at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:535)
        at org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:227)
        at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:61)
        at org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:50)
        at org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:45)
        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:43)
        at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:43)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:57)
        at org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:50)
        at org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:45)
        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:43)
        at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:43)
        at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
        at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
        at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
        at org.apache.camel.component.file.FileConsumer.pollFile(FileConsumer.java:128)
        at org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(FileConsumer.java:77)
        at org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(FileConsumer.java:84)
        at org.apache.camel.component.file.FileConsumer.poll(FileConsumer.java:57)
        at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:65)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
        at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:280)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:135)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:65)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:142)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:166)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
        at java.lang.Thread.run(Thread.java:595)
Caused by: java.io.NotSerializableException: com.company.soft.type.schema.Document
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
        at org.apache.activemq.command.ActiveMQObjectMessage.storeContent(ActiveMQObjectMessage.java:98)

2) Config

        public void configure() {

                DataFormat jaxb = new JaxbDataFormat(
                                "com.company.soft.type.schema");

                errorHandler(deadLetterChannel("seda:errors").maximumRedeliveries(1)
                                .useExponentialBackOff());
                from(
                                "file:///c:/temp/test?moveNamePrefix=c:/temp/consumed/&moveNamePostfix=old")
                                .unmarshal(jaxb)
                                .to("activemq:queue:component.queue");
                               
                               
                               
       <camelContext useJmx="true"
              xmlns="http://activemq.apache.org/camel/schema/spring">               
      <package>com.company.soft.core.routing</package>
          </camelContext> 
         
         
          <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="brokerURL" value="vm://localhost:61616?broker.persistent=false"/>
      </bean>

3) Version used : apache - Camel 1.4 SNAPSHOT, ActiveMQ - 5.1

What is the root cause of this error ?

Regards,

charles
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com