I have the following situation:
There are 2 xsd files. The 1st one defines a root element, and several types.
The second one includes the first, and extends one of the types. There is no root type defined in this file.
From the first xsd, a model is generated in a package (a). The second schema should create a new package (b) for the additional types, but reuse the generated package a. I solved this by using a binding file which points to the previously generated elements (in package a). So far this works, but..
JAXB generates a ObjectFactory in package A, which contains a create method for the root element. For the second schema, also an ObjectFactory is created in package B. And this class also had the create method for the same root element.
To be able to use all types, the jaxb context is created using
multiple object factories (newInstance(a.ObjectFactory.class, b.ObjectFactory.class)
).
At runtime this results in the following error:
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions The element name {http://www.example.org/Scenario/}scenario has more than one mapping
Should I generate the packages differently? Or is there something possible using the binding file to prevent the object factory from having duplicate methods?