I have the following beans:
1. JAXB - XMLApplication has a name, version and a list of XMLModules; XMLModule has a name and userName, where username uses a custom converter to convert between String and User
2. application beans (eventually these will be JPA entities) - Application that has a name, version and a list of Modules; Module has a name and a User
When the JAXB graph (#1) is unmarshalled, I try to create the other graph (#2). This works fine: the factories are called, the converter is called.
When I take the resulting Application instance, and try to map it back to XMLApplication, it doesn't work for the modules properties - the ones that get written to XMLApplication.modules are of type Module, simply reference-copied. The converter is not used, nor is the JAXBFactory - basically the whole mapping for XMLModule / Module is ignored.
I am attaching a test case (maven 2 project) that contains:
1. src/main/java/com.test.config - package for the Application hierarchy
2. src/main/java/com.test.dozer - package for the converter
3. src/main/generated/com.test.xml - package for the XMLApplication hierarchy, generated from my schema by JAXB plugin
4. src/main/resources/XML - application.xsd is the schema for JAXB, bindings.xjb refines the mapping slightly (influences the way code from #3 is generated) and dozerApplication.xml that is a Dozer mapping file
5. src/test/resources/XML/applicationInstance.xml - is a test XML file for JAXB to generate the graph
6. src/test/java contains one test class that unmarshalls the XML, performs the XMLApplication -> Application mapping, and then attempts to do it the other way round; is also contains a comment which point the error and the cause (ClassCastException)
The logs include the following line