Exception Information: java.lang.IllegalArgumentException: attempt to create the same field twice.
As the exception says, you are trying to generate code (JAXB) for a schema with the same name for multiple attributes and elements. The easiest way is to add a JAXB-Binding file.
JAXB binding purpose: This file is used to specify alias names for duplicate elements / attributes, i.e. if the name "id" is repeated, you can specify an alias as "id1" with the path of this element / attribute.
Sample Binding File:
<jxb:globalBindings> <xjc:simple /> </jxb:globalBindings> <jxb:bindings schemaLocation="Sample.xsd"> <jxb:bindings node="//xs:element[@name='sample']/xs:complexType/xs:attribute[@name='id']"> <jxb:property name="id1"/> </jxb:bindings> <jxb:bindings node="//xs:element[@name='innersample']/xs:complexType/xs:attribute[@name='id']"> <jxb:property name="id2"/> </jxb:bindings> <jxb:bindings node="//xs:element[@name='sample']/xs:complexType/xs:sequence/xs:element[@name='ID']"> <jxb:property name="id3"/> </jxb:bindings> <jxb:bindings node="//xs:element[@name='innersample']/xs:complexType/xs:sequence/xs:element[@name='ID']"> <jxb:property name="id4"/> </jxb:bindings> </jxb:bindings>
If you use the NETBEANS IDE to bind JAXB, add the bind file at creation time and check the "Extension" box when using XJC.
source share