#281 Recursive mapping of List properties results in ClassCastExc

Dozer v5.3.1

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


  • wujek

    wujek - 2010-09-15

    Sorry, wrong button clicked.

    The logs include the following line:
    Sep 15, 2010 12:23:55 PM org.dozer.MappingProcessor mapCollection
    WARNING: The destination object: com.test.xml.XMLApplication@265a2eaa does not have a write method
    I don't know what it refers to, the XMLApplication.modules field is configured to be directly accessible.

    I am setting the priority to 9 as we are deciding whether to go with Dozer or not, and this will have influence on the decision.

  • wujek

    wujek - 2010-09-15
    • priority: 5 --> 9
  • dmitry (lv)

    dmitry (lv) - 2010-11-07

    Your test case works after providing collection mapping hint

    <a is-accessible="true">modules</a>

    However this is still a bug as Dozer looks at generic type on setter method only. Getter is ignored. And since JAXB generated Beans does not have setter for collections hint is needed as a workaround. Will be fixed in 5.3.1 and released this week. Hope it is not too late for you...


  • dmitry (lv)

    dmitry (lv) - 2010-11-14

    fixed. Will be released in 5.3.1

  • dmitry (lv)

    dmitry (lv) - 2010-11-14
    • milestone: 1129554 --> Dozer v5.3.1
    • status: open --> closed

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks