Can xjc -version be trusted?

Posted by JasonPlutext on Stack Overflow See other posts from Stack Overflow or by JasonPlutext
Published on 2012-09-24T09:36:47Z Indexed on 2012/09/24 9:37 UTC
Read the original article Hit count: 512

Filed under:
|
|
|

I've spent the day debugging an issue with JAXB getting namespaces wrong or missing (possibly related to Marshaller.JAXB_FRAGMENT, but that's not the point here).

I found the problem occurs with JAXB RI 2.1.10 in my endorsed dir.

It is fixed if I use JAXB RI 2.2.4 or 2.2.6

Here is what is really confusing (and what made it take so long).

The problem occurs on Linux with:

$ java -version
java version "1.7.0_03"
OpenJDK Runtime Environment (IcedTea7 2.1.1pre) (7~u3-2.1.1~pre1-1ubuntu2)
OpenJDK 64-Bit Server VM (build 22.0-b10, mixed mode)

$ xjc -version
xjc 2.2.4

but it should work fine, if this java really uses JAXB RI 2.2.4 !!

Similarly, I can't reproduce the issue on Windows with Java 1.6.0_27, which reports:

C:\Program Files\Java\jdk1.6.0_27\bin>java -version
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) 64-Bit Server VM (build 20.2-b06, mixed mode)

C:\Program Files\Java\jdk1.6.0_27\bin>xjc -version
xjc version "JAXB 2.1.10 in JDK 6"
JavaTM Architecture for XML Binding(JAXB) Reference Implementation, (build JAXB 2.1.10 in JDK 6)

and yet if I put 2.1.10 RI in my endorsed dir, the problem occurs. It should occur with 1.6.0_27, if that really uses JAXB RI 2.1.10.

It seems to me that the problem I'm experiencing has been fixed in the reference implementation somewhere after 2.1.10 and before 2.2.4, but that neither of the 2 VM's above actually use the JAXB version they claim to. Or possibly they use the xjc they claim, but not what is in jaxb-api.jar and jaxb-impl.jar (I know there is a difference in the namespace prefix mapper property, but that won't be causing this problem).

I've done these experiments on Win 7 and Ubuntu, in tomcat (no eclipse), and in eclipse (no tomcat), so I'm pretty confident I'm explaining my findings correctly.

Can anyone provide any insight into what is happening?

If I'm right, does anyone know what versions of JAXB the various Sun/Oracle JDKs really use?

© Stack Overflow or respective owner

Related posts about java

Related posts about jaxb