Marshalling/Unmarshalling XML Messages
anirban.gupta4 Jul 6, 2013 3:05 PMHi,
I was trying to marshal/unmarshal messages using jaxb. For this I created a simple camel-spring project in Fuse IDE. The project structure and the files each folder contain looks as follows:
camel-spring
data
message (XML message to be unmarshalled)
src
main
java
com
mycompany
Person.java (JAXB annotated java class for the XML message)
jaxb.index (containing only the class name Person)
resources
META-INF
spring
camel-context.xml
target
the compiled classes
My camel-context.xml loks like this:
<?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:camel="http://camel.apache.org/schema/spring"
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">
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<camel:dataFormats>
<camel:jaxb id="test" contextPath="com.mycmpany"/>
</camel:dataFormats>
<camel:route>
<camel:from uri="file:D:/workspace/fuse/camel-spring/src/data?noop=true"/>
<camel:unmarshal ref="test"></camel:unmarshal>
<camel:to uri="file:target:messages"></camel:to>
</camel:route>
</camel:camelContext>
</beans>
Here the context path is com.mycompanyand the jaxb.index file is also under it. But when running this, I'm getting the following exception:
Caused by: javax.xml.bind.JAXBException: "com.mycompany" doesnt contain ObjectFactory.class or jaxb.index
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:231)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
Can you kindly suggest the changes I've to make to run this?
Regards,
Anirban.