jaxb-ri icon indicating copy to clipboard operation
jaxb-ri copied to clipboard

xjc generates duplicated 'create' methods in ObjectFactory when using episode file

Open patric-r opened this issue 1 year ago • 1 comments

Hi there,

We have a rather complex set of schema files. The schema files can be grouped into 2 parts, one generic part A and one specific part B which reuses types from A.

As always, we use xjc to generate jaxb classes for part A and let xjc generate an episode file. When generating the jaxb classes for part B we used that episode file in order to avoid duplicate class creation which works perfectly.

However, when looking into the ObjectFactory of part B, it suprisingly contains create methods for classes of part A and those create methods are already part of the ObjectFactory of part A.

As a result, when marshalling our JAXB tree, it fails with:

java.util.concurrent.CompletionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 3 counts of IllegalAnnotationExceptions
The element name {http://namespace/of/part/A has more than one mapping.
    this problem is related to the following location:
at public javax.xml.bind.JAXBElement com.part.B.xml.ObjectFactory.createProblematicType(com.part.A.xml.ProblematicType)

When manually removing those redudant create methods from part B's ObjectFactory, everything works as expected.

Question: Why does xjc create those duplicate create() methods?

(Note: jaxb 2.3.5 has been used)

patric-r avatar Aug 09 '23 10:08 patric-r

Hi @patric-r

Could you test with latest jaxb 2.3.8 release and say if this solve your issue ?

What tool do you use to generate java files from schema ?

Thanks for your responses

laurentschoelens avatar Sep 02 '23 16:09 laurentschoelens