I am getting below error while maven build using jaxb(maven-jaxb2-plugin) compiler
A class/interface with the same name "org.somePackage.customer" is already in use.
Use a class customization to resolve this conflict.
at com.sun.tools.xjc.util.CodeModelClassFactory.createClass(CodeModelClassFactory.java:121)
at com.sun.tools.xjc.util.CodeModelClassFactory.createClass(CodeModelClassFactory.java:82)
at com.sun.tools.xjc.generator.bean.ImplStructureStrategy$1.createClasses(ImplStructureStrategy.java:82)
at com.sun.tools.xjc.generator.bean.BeanGenerator.generateClassDef(BeanGenerator.java:437)
at com.sun.tools.xjc.generator.bean.BeanGenerator.getClazz(BeanGenerator.java:469)
at com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:194)
at com.sun.tools.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:166)
at com.sun.tools.xjc.model.Model.generateCode(Model.java:290)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.generateCode(XJC22Mojo.java:70)
Relevant XSD code snippet because of which error is coming
<xsd:element name="customer" >
........
</xsd:element>
<xsd:element name="permanentCustomer" type="customer"/>
Relevant pom section for maven-jaxb2-plugin is
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.3</version>
<configuration>
<schemaDirectory>src/main/resources/META-INF/schema</schemaDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
What works
If I introduce block="substitution"
it works
<xsd:element name="customer" block="substitution">
........
</xsd:element>
<xsd:element name="permanentCustomer" type="customer"/>
After doing research on net,My guess is jaxb compiler again trying to create the customer class based on element name="permanentCustomer"
which it has already created based on element name ="customer".
So I don't want to create java object for permanentCustomer while unmarshalling as it has been already created while customer creation.
I can think of two solutions
1)Some configuration For maven-jaxb2-plugin plugin where if java class has been already generated, don't to regenerate it again and proceed
2)Or Mentioning some attribute at xml level to ignore specific elements ?
Is there any configuration exists ?