Skip to content
Advertisement

JAXB UnMarshalling Renders Null Values (JAXB, Java 1.8)

I have an XSD which I have written like this:

JavaScript

Now I generate the JAXB classes using CXF maven plugin. And i get a JAXB class like (used a decompiler for this):

JavaScript

Now to get it out, I wrote a simple class that just takes a string and unmarshalls it:

JavaScript

But that last line prints null. I was expecting it to print the value 16365343278450M. In fact every value in aMessage object is null (scope, type etc).

I am suspecting that there might be something wrong with the XSD i wrote, that making it go wrong as domino effect.

Any pointers would be helpful. Thanks in advance.

Advertisement

Answer

I was able to fix it myself. There were two ways of doing it.

First was to change the string like:

JavaScript

or change the XSD elementFormDefault in the XSD and keep this original string without the namespace.

JavaScript

I went for the latter as it was more manageable for me.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement