views:

280

answers:

1

I am using JAXB to unmarshal an XML file into an object tree. The root object is non-null, but all of it's members are null even though there is data in the XML file. My object classes were generated with Axis2 from wsdls. I have the ObjectFactory class, the jaxb.index class, the package.info annotation, etc.

My problem is the same as this discussion: http://old.nabble.com/AXIS2,-JAXB---Unmarshalling-td26847419.html

First and foremost: is there a way I can get it to fill the data properly?

If not, is there a good substitute library for either Axis2 or JAXB that does the same thing but that will play nicely with each other?

+2  A: 

JAXB by default silently ignores errors. I can only assume that this is because the developers are not very good. Try adding this code to throw an exception if something goes wrong.

unmarshaller.setEventHandler( new ValidationEventHandler() {

public boolean handleEvent( ValidationEvent event ) { throw new RuntimeException( event.getMessage(), event.getLinkedException() ); } } );

Jesse Barnum