Came up against a problem with (JibX) marshalling an object down to XML. Part of the problem was not finding any reference to what the error message means. So for future generations I’ve documented it here. The error message is:
org.springframework.oxm.jibx.JibxMarshallingFailureException: JiBX marshalling exception: Supplied root object of class java.util.LinkedList cannot be marshalled without top-level mapping; nested exception is org.jibx.runtime.JiBXException: Supplied root object of class java.util.LinkedList cannot be marshalled without top-level mappingAlthough I had all the marshalling beans set up I was passing in a collection instead of the object that JibX was expecting. For example:
ListOfUuids lou = new ListOfUuids () ;
lou.setList (export) ;
String xml = MarshallerUtils.convertObjectToXML (marshaller, export) ;
Which should have been (see line 3):
ListOfUuids lou = new ListOfUuids () ;
lou.setList (export) ;
String xml = MarshallerUtils.convertObjectToXML (marshaller, lou) ;
An easy mistake to make, but made more difficult to find by not knowing what the error message means!