Question

Let's say I have the following two classes:

package example.model;

public class Model {
    public static class Inner {}

    public Other prop;
}

and

package example.model;

public class Other {
    public static class Inner {}

    public String prop;
}

and I create a JAXB context with JAXBContext.newInstance(example.model.Model.class).

With the default JAXB implementation from Java 6 this works without any annotations, and a generated model does not mention "inner". with EclipseLink I get a "Name collision. Two classes have the XML type with uri and name inner."

I know that making at least one of the inner classes @XmlTransient gets rid of the problem. What I would like to know is how this difference relates to the JAXB standard, and, I guess, also if there is any other way to make MOXy ignore these classes like the default JAXB implementation does.

Was it helpful?

Solution

This appears to be a bug in EclipseLink JAXB (MOXy). We are currently working on a fix for the EclipseLink 2.3.3 and 2.4.0 streams. You can track our progress using the following link:

Once the fix is available you will be able to download a nightly build from the following link:

Workaround

As you mention you can mark the static inner class with @XmlTransient.

package example.model;

public class Model {
    @XmlTransient        
    public static class Inner {}

    public Other prop;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top