Page 1 of 1

Building from source and JAXB

PostPosted: Fri Jan 29, 2010 11:06 am
by joshuajborn
I've been trying to build docx4j from source, from the 2.2.2 release tag.

I managed to snag all the dependencies via Maven, and once I altered the "m2Repository" property in the build.xml to actually point at my maven repository, the ant dist seemed to start to work, except it hit these JAXB related no package found errors:

Code: Select all
    [javac] C:\temp\svn\docx4j\src\main\java\org\docx4j\jaxb\NamespacePrefixMapper.java:30: package com.sun.xml.bind.marshaller does not exist
    [javac] public class NamespacePrefixMapper extends com.sun.xml.bind.marshaller.NamespacePrefixMapper {
    [javac]                                                                       ^
    [javac] C:\temp\svn\docx4j\src\main\java\org\docx4j\jaxb\NamespacePrefixMapperRelationshipsPart.java:23: package com.sun.xml.bind.marshaller does not exist
    [javac] public class NamespacePrefixMapperRelationshipsPart extends com.sun.xml.bind.marshaller.NamespacePrefixMapper {
    [javac]                                                                                        ^
    [javac] C:\temp\svn\docx4j\src\main\java\org\docx4j\jaxb\NamespacePrefixMapperUtils.java:18: incompatible types
    [javac] found   : org.docx4j.jaxb.NamespacePrefixMapper
    [javac] required: java.lang.Object
    [javac]           return new NamespacePrefixMapper();
    [javac]                  ^
    [javac] C:\temp\svn\docx4j\src\main\java\org\docx4j\jaxb\NamespacePrefixMapperUtils.java:39: incompatible types
    [javac] found   : org.docx4j.jaxb.NamespacePrefixMapperRelationshipsPart
    [javac] required: java.lang.Object
    [javac]           return new NamespacePrefixMapperRelationshipsPart();
    [javac]                  ^
    [javac] C:\temp\svn\docx4j\src\diffx\com\topologi\diffx\algorithm\DiffXFactory.java:150: warning: non-varargs call of varargs method with inexact argument type for last parameter;
    [javac] cast to java.lang.Object for a varargs call
    [javac] cast to java.lang.Object[] for a non-varargs call and to suppress this warning
    [javac]       diffex = (DiffXAlgorithm)cons.newInstance(new EventSequence[]{sequence1, sequence2});
    [javac]                                                 ^


I saw that the build.xml is set to compile for a JDK 1.5 target, so I thought I'd try switching to JDK 1.5 and installing the JWSDP, but all that did was increase the number of package javax.xml.bind.*not found errors to one hundred. (This is after adding the JAXB libs to the classpath both by adding a pathelement to the "jre.libs" path and by actually copying the jaxb jars to the libs folder of my JDK.)

Is there something going on in this build process I'm missing?

Re: Building from source and JAXB

PostPosted: Fri Jan 29, 2010 12:52 pm
by jason
Hi Joshua

To build from source, you should be running Java 6 JDK, so you have the JAXB which is included in that; you also need to download and add to your classpath the JAXB reference implementation. (Depending on your environment, Maven may have done this already)

This is because the reference implementation contains com.sun.xml.bind.marshaller.NamespacePrefixMapper, and Java 6 contains com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper

The reason for this is to ensure that end users are able to user either JAXB in conjunction with the docx4j binary jar. The price of that is that you need both JAXB implementations to build docx4j.

cheers .. Jason

Re: Building from source and JAXB

PostPosted: Sat Jan 30, 2010 1:08 pm
by joshuajborn
jason wrote:Hi Joshua

To build from source, you should be running Java 6 JDK, so you have the JAXB which is included in that; you also need to download and add to your classpath the JAXB reference implementation. (Depending on your environment, Maven may have done this already)

This is because the reference implementation contains com.sun.xml.bind.marshaller.NamespacePrefixMapper, and Java 6 contains com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper

The reason for this is to ensure that end users are able to user either JAXB in conjunction with the docx4j binary jar. The price of that is that you need both JAXB implementations to build docx4j.

cheers .. Jason


I figured it was something like when I saw that the JAXB library had been moved into the SDK. Thanks for the tip.