I've build a war file from my web application using NetBeans 7.2 (in Windows 7 environment!), which runs correctly during test phase with GlassFish 3.1.2 server within NetBeans context.
The defined namespace within the package-info.java
file is correctly added to my xml file.
However when I deploy the war file in a seperatetely running GlassFish server on a Linux machine the namespace is set to the default ns1 and NOT to the one defined by the package-info.java file?
What am I doing wrong?
Regards, Gerard
Why is JAXB namespace of my xml set to default ns1?
ns1
is not the namespace but the prefix. The prefix is not significant. For example the following documents are all equivalent. The foo
element is in the FOO
namespace, and the bar
element is in the BAR
namespace.
<a:foo xmlns:a="FOO" xmlns:b="BAR>
<b:bar>Hello World</b:bar>
</a:foo>
<ns1:foo xmlns:ns1="FOO" xmlns:ns2="BAR>
<ns2:bar>Hello World</ns2:bar>
</ns1:foo>
<foo xmlns="FOO" xmlns:b="BAR>
<b:bar>Hello World</b:bar>
</foo>
What am I doing wrong?
Nothing. A JAXB (JSR-222) implementation is not required to use the prefix specified in the @XmlSchema
annotation. EclipseLink JAXB (MOXy) does and recent versions of the JAXB RI appear to. The version/implementation of JAXB in NetBeans 7.2 appears to, while the version/implementation of JAXB that GlassFish 3.1.2 uses does not.
Below is a link to an article that I wrote that goes into a little more detail and covers the NamespacePrefixMapper
extension that may be useful here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With