Jibx seems to take the wrong mapping definitions when mapping a collection, that results in a ClassCastException.
I have the following piece of xml: ---- <group key='keyG1'> <item key='keyG1I1'> <value>keyG1I1V</value> </item> </group> <group key='keyG2'> <group key='keyG2.1'> <item key='keyG2.1I1'> <value>keyG2.1I1V</value> </item> </group> </group> --- And the mapping snippet looks like this: ---- <mapping name="group" class="com.bv.core.domain.impl.ContentItemGroupDefault" extends="com.ited.domain.impl.EntityDao" post-set="postSet" ordered="false"> <collection field="childGroups" usage="optional" item-type="com.bv.core.domain.ContentItemGroup" create-type="java.util.HashSet" /> <collection field="contentItems" usage="optional" item-type="com.bv.core.domain.ContentItem" create-type="java.util.HashSet" /> </mapping> <mapping name="item" class="com.bv.core.domain.impl.ContentItemDefault" extends="com.ited.domain.impl.EntityNameKeyValueDao" ordered="false" post-set="postSet"> <structure map-as="com.ited.domain.impl.EntityNameKeyValueDao"/> <collection field="toolTips" usage="optional" create-type="java.util.HashSet" /> </mapping> ---- And the exception when marshaling the above xml: --- java.lang.ClassCastException: com.bv.core.domain.impl.ContentItemDefault cannot be cast to com.bv.core.domain.ContentItemGroup at com.bv.core.domain.impl.JiBX_jibx_binding_declare_overviewMungeAdapter.JiBX_ jibx_binding_declare_overview_unmarshal_1_1() ---- The first <group> doesn't contain a nested <group> element, so it should simple ignore the <collection group> binding as it's "optional". However, Jibx picks up <item>, marshal it to a ContentItemDefault class and then add it to the first encountered collection of the group binding, namely the childGroups collection. It should however ignore this and use the contentItems collection. If put the "contentItems collection mapping before the "childGroup" collection mapping I get the following ClassCastException, probably because it fails in the second nested group xml snippet: --- java.lang.ClassCastException: com.bv.core.domain.impl.ContentItemGroupDefault cannot be cast to com.bv.core.domain.ContentItem ---- How do I solve this? How do I tell JibX to insert in the correct collection? - Ed ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users