JAXB appears to fail silently in some cases if the XML it’s attempting to unmarshall to mapped classes doesn’t have the necessary mapped properties.
You can get additional output by adding the following:
– displays information during JAXB initialization
Before you call unmarshall() on your Unmarshaller, call setEventHandler() and add a DefaultValidationEventHandler as follows:
Unmarshaller um = jaxbContext.createUnmarshaller(); um.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
– this will output additional failure information about missing mappings for xml elements, useful if your mapped class ends up with missing values.
3 Replies to “Debugging JAXB unmarshalling issues”
Where do you specify that property? application.properties file in Sprint boot?
I am using application.yml file. How do I configure it in application.yml file.
Java system properties passed with -D are passed in on the command line when you start your app. There might be a way to pass them more easily with Spring Boot’s property file (I’m not familiar if there is or not), but passing them on the command line is easy (if you’re running Spring Boot with ‘java -jar’ or if running on an app server you’ll need to pass in the startup options for your server)
added the above, no additional information provided in any log or console.
Any additional ideas?