Which artifacts should I use for JAXB RI in my Maven project?

After clarification with Oracle, the following artifacts should be used:

Runtime

If you want to unmarshal XML to Java objects or marshal Java objects as XML:

<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>...</version>
</dependency>

Schema compiler (XJC)

If you have an XML Schema and want to generate the Java code out of it:

<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-xjc</artifactId>
    <version>...</version>
</dependency>

Schema generator (JXC/schemagen)

If you have Java classes with JAXB annotations and want to generate a XML Schema based on them:

<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-jxc</artifactId>
    <version>...</version>
</dependency>

The two latter artifacts (org.glassfish.jaxb:jaxb-xjc and org.glassfish.jaxb:jaxb-jxc) are wrapped by Maven plugins so you normally would not need them in the runtime.

Eclipse usage

If your Maven projects somehow don’t get the full classpath, turn on debug output and check the Maven console. You might be seeing the following error message there:

[ERROR] ‘dependencyManagement.dependencies.dependency.systemPath’ for com.sun:tools:jar must specify an absolute path but is ${tools.jar} @

This is due to the following problem:

Maven not picking JAVA_HOME correctly

The solution by @rustyx is to add -vm option to the eclipse.ini:

-vm
<PATH_TO_JDK>\jre\bin\javaw.exe

Leave a Comment