I can't tell any thing is wrong according to your camel route.
Can you check if there any error log ?
BTW, which version of camel are you using?
I added a few processors in my route for debugging and changed a few things:
// setup JAXB, This is important otherwise the XML will not get unmarshalled properly
//JAXBContext context = JAXBContext.newInstance(MyObject.class);
String pkg = ObjectFactory.class.getPackage().getName();
JaxbDataFormat jaxb = new JaxbDataFormat(pkg);
// consume messages from simulation
.unmarshal(jaxb) // the output of this is my object but no fields are populated
I was able to get the class MyObject to unmarshal however the content is empty.
results in an object
c.getSomeElement(); // this returns null
One of the things I find very annoying and confusing is that JAXB is not verbose at all. I turned on debugging and I get no errors, warnings, or exceptions.
Edited by: jamie3 on Jun 15, 2011 6:44 PM
OK i seem to have found the issue why JAXB is creating an empty object.
I wrote a unit test which sends both XML documents to the unmarshaller, for example:
I did some debugging and it appears that the second case works. Thus the XML header must be included in order for JAXB to successfully unmarshal the string.
The problem with this is I have a 3rd party system generating the XML document and publishing to my Foo queue. Unfortunately this system does not publish the XML header.
Is there a way around this?
Ok the JAXB generated Java object is now being populated. It looked like there was a type in the namespace.