Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in AnnotationProcessor.updateGlobalElements() for substituable elements #1856

Open
jeremybalan opened this issue Apr 4, 2023 · 0 comments

Comments

@jeremybalan
Copy link

Hello,

I'm working with an editor who provides us XSD schemas using "abstract" elements and "susbtituableGroups" keyword, and it seems to be a problem with this kind of usage using your org.eclipse.persistence.moxy JAXB Implementation.

Actually we use your last release version 4.0.1 but no matter using any versions 2.XX, 3.XX or 4.XX, we are facing a random NullPointerException while creating JaxbContext in your org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor class, updateGlobalElements method, Line 3985 (rootDeclaration is null).

"random" because it's not always the same XSD element concerned (but always a substituable element), and sometimes, very rarely, it can pass without NullPointerException.

Using debug mode, we can see that the variable "next" in method updateGlobalElements is an XSD element that has a abstract type as substitutionGroup defined in one XSD :
<xs:element name="the value of the 'next' variable" type="its_type" substitutionGroup="xxxx_abstract" /> (xxxx_abstract corresponds to the variable substitutionHead in method updateGlobalElements)

And in another XSD, we have the declaration of the abstract element :
<xs:element ref="xxxx_abstract" minOccurs="0" maxOccurs="unbounded" /> in a complex type (which is not the root type)
...
<xs:element name="xxxx_abstract" abstract="true" />

The problem is only when we create the JaxbContext using the root (@XmlRootElement annotation) element class generated from the XSDs. We don't reproduce it when we create the JaxbContext context using the package name of the generated model nor the generated ObjectFactory class.

To sum up :
JAXBContext.newInstance(myPackage.MyRootElement.class) ==> random NullPointerException
JAXBContext.newInstance(myPackage.ObjectFactory.class) ==> OK
JAXBContext.newInstance("myPackage") ==> OK

Generation of the model is done using XJC by a Jaxb maven plugin
Java 8 or Java 17 : no matter, we face the problem
It's on a spring boot API.

Thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant