Page 1 of 1

Building DocX4J

PostPosted: Wed Dec 17, 2008 7:57 pm
by ryan_hire
I would like to build the Dox4J project. So I followed the instructions on http://dev.plutext.org/trac/docx4j/wiki/DevEnv and I am using Java 1.6_10 with maven 2.0.9 ant 1.6.2 and on windows XP. As instructed I executed :
svn co http://dev.plutext.org/svn/docx4j/trunk/docx4j docx4j : which I assume got me the latest trunk version.

When executing the mvn install command I received the following error:
Code: Select all
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.docx4j.diff.ParagraphDifferencerTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.032 sec <<< FAILURE!
Running org.docx4j.samples.HyperlinkTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec <<< FAILURE!

Results :

Tests in error:
  initializationError0(org.docx4j.diff.ParagraphDifferencerTest)
  initializationError0(org.docx4j.samples.HyperlinkTest)

Tests run: 2, Failures: 0, Errors: 2, Skipped: 0
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.
Please refer to C:\projects\docx4j\target\surefire-reports for the individual test results.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10 seconds
[INFO] Finished at: Wed Dec 17 13:34:36 CST 2008
[INFO] Final Memory: 18M/57M
[INFO] ------------------------------------------------------------------------


In looking in the Surefire logs I see the details of the error:

Code: Select all
-------------------------------------------------------------------------------
Test set: org.docx4j.diff.ParagraphDifferencerTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.032 sec <<< FAILURE!
initializationError0(org.docx4j.diff.ParagraphDifferencerTest)  Time elapsed: 0.016 sec  <<< ERROR!
java.lang.Exception: Method testDiffDocx() should not be static
   at org.junit.internal.runners.MethodValidator.validateTestMethods(MethodValidator.java:67)
   at org.junit.internal.runners.MethodValidator.validateInstanceMethods(MethodValidator.java:28)

and
Code: Select all
Test set: org.docx4j.samples.HyperlinkTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec <<< FAILURE!
initializationError0(org.docx4j.samples.HyperlinkTest)  Time elapsed: 0 sec  <<< ERROR!
java.lang.Exception: No runnable methods


At that point I wasn't sure what to do, but I thought I would try to go ahead and do an ant dist to build the docx4j jar file by calling ant dist and it came back with quite a few compiler errors.
Code: Select all
build-project:
     [echo] docx4j: C:\projects\docx4j\build.xml
    [javac] Compiling 735 source files to C:\projects\docx4j\bin
    [javac] C:\projects\docx4j\src\main\java\org\docx4j\JcrNodeMapper\AlfrescoJcrNodeMapper.java:22: package javax.jcr does not exist
    [javac] import javax.jcr.Node;
    [javac]                 ^
    [javac] C:\projects\docx4j\src\main\java\org\docx4j\JcrNodeMapper\AlfrescoJcrNodeMapper.java:23: package javax.jcr does not exist
    [javac] import javax.jcr.Property;


one weird thing is that it also seemed to be complaining about log4j:

Code: Select all
    [javac] C:\projects\docx4j\src\main\java\org\docx4j\JcrNodeMapper\AlfrescoJcrNodeMapper.java:32: cannot find symbol
    [javac] symbol  : class Logger
    [javac] location: class org.docx4j.JcrNodeMapper.AlfrescoJcrNodeMapper
    [javac]     private static Logger log = Logger.getLogger(AlfrescoJcrNodeMapper.class);
    [javac]                    ^


In looking at the M2 directory I don't see either log4j or javax.jcr
Code: Select all
12/17/2008  01:11 PM    <DIR>          com
12/17/2008  01:10 PM    <DIR>          docx4j
12/17/2008  01:10 PM    <DIR>          org
12/17/2008  01:11 PM    <DIR>          pdf-renderer
12/17/2008  01:10 PM    <DIR>          webdavclient4j
12/17/2008  01:10 PM    <DIR>          xalan
12/17/2008  01:10 PM    <DIR>          xhtmlrenderer


Do I need to manually add either log4j or the javax.jcr jars somewhere?
Do I need to be building with a different version of Java, ant, or maven?
Or is there something that I missed?

Thanks

Re: Building DocX4J

PostPosted: Wed Dec 17, 2008 11:01 pm
by jason
Hi Ryan

docx4j uses maven to manage the dependencies in your IDE (eg Eclipse). I don't actually use Maven from the command line to do anything really except to generate a dependency tree, so that error with org.docx4j.diff.ParagraphDifferencerTest isn't a surprise.

docx4j does use ant to do builds.

As to your specific errors, looking at pom.xml, i see:

Code: Select all
      <dependency>
         <groupId>javax.jcr</groupId>
         <artifactId>jcr</artifactId>
         <version>1.0</version>
      </dependency>
      <dependency>
         <groupId>log4j</groupId>
         <artifactId>log4j</artifactId>
         <version>1.2.13</version>
      </dependency>


And looking at build.xml, I see:

Code: Select all
        <pathelement location="${m2Repository}/javax/jcr/jcr/1.0/jcr-1.0.jar"/>
        <pathelement location="${m2Repository}/log4j/log4j/1.2.13/log4j-1.2.13.jar"/>


Have you got m2eclipse configured? Either it or running mvn from the command line should have pulled down those 2 jars for you.

If for whatever reason maven can't get those jars for you, you could download them manually and alter build.xml to reference wherever you put them. Of course, you'll also need to change your build path in Eclipse if you want it to be happy to.

Finally, yes, re your svn co, you are using the correct sources.

cheers

Jason

Re: Building DocX4J

PostPosted: Sat Jun 20, 2009 3:15 am
by dqkit
I've tried to build the project just now. But failed.
I got an exception, i says "6/20/09 9:23:57 AM CST: Unable to read docx4j/pom.xml; java.lang.UnsupportedOperationException"

I've set my jre as:
Code: Select all
      <profile>
         <id>jdk16</id>
         <activation>
            <jdk>1.6</jdk>
         </activation>
         <dependencies>
            <dependency>
               <groupId>com.sun.xml.bind</groupId>
               <artifactId>jaxb-impl</artifactId>
               <version>2.0</version>
               <scope>system</scope>
                <systemPath>${JAVA_HOME}/jre/lib/rt.jar</systemPath>
            </dependency>
         </dependencies>
      </profile>
   </profiles>


BTW, I use WinXP, JDK1.60

does anybody know how to fix it ? thank you.

Re: Building DocX4J

PostPosted: Sat Jun 20, 2009 6:11 am
by jason
Try running mvn from within the docx4j dir?

docx4j only uses maven to get the dependencies.

Build with ant:

ant dist

Another way to get the dependencies is from the binary download which you probably already have.

Hope this helps. .. Jason

Re: Building DocX4J

PostPosted: Sat Jun 20, 2009 11:09 am
by dqkit
Very appreciate for your reply.
thank you, jason!