Is there a JAXB-API installation bug in Nuxeo apt package?

I notice that the 6.0-01 package installs:

/var/lib/nuxeo/server/nxserver/lib/jaxb-impl-2.0.3.jar

But after https://jira.nuxeo.com/browse/NXP-12617, Jersey 1.17.1 is required by Nuxeo, and this requires JAXB API 2.1+. I believe this is causing an issue with a Marketplace package I have written that depends on jersey-json with ${jersey.version} (Nuxeo's variable). After the base install, I see these results:

     /var/lib/nuxeo/server/endorsed/jaxb-api-2.0.jar
     /var/lib/nuxeo/server/nxserver/lib/cxf-rt-databinding-jaxb-2.6.8.jar
     /var/lib/nuxeo/server/nxserver/lib/jaxb-impl-2.0.3.jar

And after my package is installed, I see this:

     /var/lib/nuxeo/server/endorsed/jaxb-api-2.0.jar
     /var/lib/nuxeo/server/nxserver/lib/cxf-rt-databinding-jaxb-2.6.8.jar
     /var/lib/nuxeo/server/nxserver/lib/jaxb-impl-2.2.3-1.jar
     /var/lib/nuxeo/server/nxserver/lib/jaxb-api-2.2.2.jar
     /var/lib/nuxeo/server/nxserver/lib/jaxb-impl-2.0.3.jar

This leads to startup failures complaining about the old and new versions of JAXB.

The only dependencies I declare that has anything to do with this are:

<dependency>
  <groupId>com.sun.jersey</groupId>
  <artifactId>jersey-json</artifactId>
  <version>${jersey.version}</version>
</dependency>

<dependency>
  <groupId>com.sun.jersey.contribs</groupId>
  <artifactId>jersey-multipart</artifactId>
  <version>${jersey.version}</version>
</dependency>
0 votes

1 answers

2517 views

ANSWER

After a second review it seems like the 2.0 jar might not be part of the problem:

java.lang.LinkageError: JAXB 2.1 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/var/lib/nuxeo/server/nxserver/lib/jaxb-impl-2.2.3-1.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.2 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See http://java.sun.com/j2se/1.6.0/docs/guide/standards/)

I'm not sure why depending on the same version of Jersey for jersey-json that Nuxeo uses for jersey-core causes this problem, though.

12/29/2014



I ended up doing the following adaptation of the Marketplace packaging we use (based on Nuxeo Marketplace packaging examples on GitHub):

Add an endorsed section to the install.xml template in src/main/resources:

 <install>
  @BUNDLES@
  @LIBS@
  @PROPERTIES@
  @TEMPLATES@
  @ENDORSED@
 </install>

Add code to the assembly.xml file to generate an instruction to copy the jaxb-api jar to endorsed/:

<var name="install.endorsed" value="" />
<if>
  <available file="${outdir}/marketplace/install/lib/jaxb-api-2.2.2.jar" />
  <then>
    <var name="install.endorsed"
         value="${line.separator}
                &lt;copy file=&quot;${package.root}/install/lib/jaxb-api-2.2.2.jar&quot;${line.separator}
                todir=&quot;${env.server.home}/endorsed&quot; overwrite=&quot;true&quot; /&gt;${line.separator}
                &lt;delete file=&quot;${env.server.home}/endorsed/jaxb-api-2.0.jar&quot; /&gt;" />
  </then>
</if>
<copy file="src/main/resources/install.xml"
      todir="${outdir}/marketplace"
      overwrite="true">
    <filter token="BUNDLES" value="${install.bundles}" />
    <filter token="LIBS" value="${install.libs}" />
    <filter token="PROPERTIES" value="${install.properties}" />
    <filter token="TEMPLATES" value="${install.templates}" />
    <filter token="ENDORSED" value="${install.endorsed}" />
</copy>

This produces the effect of removing jaxb-api-2.0.jar and adding jaxb-api-2.2.2.jar to the endorsed/ directory when our custom package is installed. I do not see any obvious problems when I restart Nuxeo and use it on my development machine. However, this seems like a brittle way to address this JAXB API JAR versioning issue.

Is there any better solution?

0 votes



Thanks, we shouldn't include things in endorsed anymore as the JDK has a more recent version now. This dates from a while back. I opened NXP-16270 to review and fix this.
12/29/2014

Thanks… with that news it seems like handling the workaround (removal of the jaxb-api-2.0.jar) is better done in our server configuration management instead of in the Marketplace package like above.
12/29/2014