Page 1 of 1

Docx4j compilation error

PostPosted: Wed Sep 08, 2010 6:49 pm
by Logod
Hi,

I tried to compile this simple code, but I have a compilation error.

Code: Select all
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;

public class CreateWordprocessingMLDocument {
   
   public static void main(String[] args) throws Exception {               
      WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();      
   }
   
}


Eclipse gives me:
Code: Select all
Creating package..
08.09.2010 08:57:03 *DEBUG* PartName: Trying to create part name / (PartName.java, line 150)
08.09.2010 08:57:03 *DEBUG* PartName: /_rels/.rels part name created. (PartName.java, line 117)
08.09.2010 08:57:03 *DEBUG* PartName: /docProps/core.xml part name created. (PartName.java, line 117)
08.09.2010 08:57:03 *DEBUG* PartName: / part name created. (PartName.java, line 117)
08.09.2010 08:57:03 *DEBUG* PartName: / part name created. (PartName.java, line 170)
Exception in thread "main" java.lang.NoClassDefFoundError: org/jvnet/jaxb2_commons/ppp/Child
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClassCond(Unknown Source)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.access$000(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at org.docx4j.openpackaging.packages.WordprocessingMLPackage.createPackage(WordprocessingMLPackage.java:382)
   at CreateWordprocessingMLDocument.main(CreateWordprocessingMLDocument.java:14)
Caused by: java.lang.ClassNotFoundException: org.jvnet.jaxb2_commons.ppp.Child
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 14 more


For Docx4j installation, I followed this guide
http://dev.plutext.org/svn/docx4j/trunk ... arted.html

I use:
- jdk-6u20
- docx4j-2.5.0.jar (I tried also with the nightly build, I have the same error message)
- log4j-1.2.15.jar

The OS is windows XP SP3 and Eclipse is “Helios” build id: 20100617-1415.

For log4j I use a « log4.properties » file.

I search on google for « java.lang.NoClassDefFoundError ». I found lots of topics but I didn’t understand how to apply them to Docx4j.

Maybe I only miss a step in the "GettingStarted" tutorial.

Thanks for your help.

Re: Docx4j compilation error

PostPosted: Wed Sep 08, 2010 7:17 pm
by jason
That's the parent pointer plugin jar its complaining about.

docx4j's dependencies are listed in its pom.xml, and also in build.xml. I think its the Maven related steps you missed (did you install m2eclipse?)

You can find the jars in http://dev.plutext.org/docx4j/docx4j-2.5.0/

Re: Docx4j compilation error

PostPosted: Thu Sep 09, 2010 12:20 am
by Logod
Hi,

No, m2eclipse was not installed.

So I install m2eclipse.
I folowed the video instruciton here :
http://m2eclipse.sonatype.org/installing-m2eclipse.html

And I had all the jar dependencies from this directory http://dev.plutext.org/docx4j/docx4j-2.5.0/

Now, it’s working perfecly, I can generate docx.

If I can make a remark. I am not a programmer (I learn by myself) and when I read the "GettingStarted" tutorial I think the dependencies was required only for build Docx4j from source.

Thank you very much for your quick answer and for your help.

Re: Docx4j compilation error

PostPosted: Mon Sep 13, 2010 12:17 pm
by jason
Logod wrote:when I read the "GettingStarted" tutorial I think the dependencies was required only for build Docx4j from source.


No, projects often require supporting jars. Docx4j is no exception.

The "Using docx4j binaries" section does mention this.

I probably made your life more difficult by assuming you were building from source - sorry about that!

Re: Docx4j compilation error

PostPosted: Mon Sep 13, 2010 5:39 pm
by Logod
I probably made your life more difficult by assuming you were building from source - sorry about that!

Yes, but your API is very easy to use and save me lots of time. Thanks for your hard work.