1
votes

I have 2 classes in .xsd format that have same name . Even though each one of them is under different namespace :

When i try too initialize JAXBContext i get : Two classes have the same XML type name "picture". Use @XmlType.name and @XmlType.namespace to assign different names to them. Info: Running on java 11. and generate classes with xjc. This was previously working on java 8

<xs:schema targetNamespace="http://test.com/bla/blabla/blablabla/sd" 
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="picture">






<xs:schema targetNamespace="http://test.com/bla/blabla/blablabla/hd" 
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="picture">

ANd both generated classes look like this:

@XmlRootElement(name = "picutre") public class Picture { }

I initialize JAXBContext:

 private static JAXBContext initializeJaxbContext() {
    JAXBContext jaxbctx = JAXBContext.newInstance(com.test.bla.blabla.blablabla.hd.Picture.class,com.test.bla.blabla.blablabla.sd.Picture.class);

Why do i get this error? Two classes have the same XML type name.Use @XmlType.name and @XmlType.namespace to assign different names to them Can anyone help?

1

1 Answers

0
votes

The problem was that jaxb runtime was inside a war file as transitive dependency of an other package. The solution was to exclude this in gradle file and have all jaxb dependencies under tomcat lib folder.