I have two Maven JAXB Projects.
A: Main Maven JAXB stubs XSD project, this contains BASKET.xsd
B: Maven JAXB stubs User-Project that wants to wrap BASKET.xsd in their own Objects.
This results in TWO Objects factories (different packages), both declare the following...
@XmlElementDecl(namespace = "http://www.bob.org/bob/namespace/", name = "Basket")
public JAXBElement<BasketType> createBasket(BasketType value) {
return new JAXBElement<BasketType>(QNAME, BasketType.class, null, value);
}
This generation is done via this plugin... org.jvnet.jaxb2.maven2 maven-jaxb2-plugin 0.13.2
On application start I get CXF-RT-Frotnend-JaxRS 3.1.11 giving me an error...
017-07-03 14:38:54,613845801: WARN : [RMI TCP Connection(3)-127.0.0.1] [] org.apache.cxf.jaxrs.utils.ResourceUtils: No JAXB context can be created
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
The element name {http://www.bob.org/bob/namespace/}Basket has more than one mapping.
this problem is related to the following location:
at public javax.xml.bind.JAXBElement com.bob.bean.ObjectFactory.createBasket(org.bob.BasketType)
at com.bob.bean.ObjectFactory
this problem is related to the following location:
at public javax.xml.bind.JAXBElement org.userservice.bean.ObjectFactory.createBasket(org.bob.BasketType)
This wasn't an error I got untill I upgraded from CXF 2.7.7 to 3.1.11
Does anyone know if there is a way to get maven-jaxb2-plugin to not generate the method createBasket(..) on the UserService ObjectFactory??
Or to get CXF to accept the two methods, which are identical, on the two ObjectFactoty classes?
My soloution was to change
<property name="singleJaxbContext" value="true"/>
to
<property name="singleJaxbContext" value="false"/>
e.g. in my application-config.xml
<bean id="jaxbextprovider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
<property name="singleJaxbContext" value="false"/>
</bean>