Page 1 of 1

docx4j-2.8.0-SNAPSHOT NoClassDefFoundError FinalArrayList

PostPosted: Sun Mar 13, 2016 7:16 pm
by digler99
Hi, I can't seem to get docx4j to work on android using ae-docx4j-2.8.0-SNAPSHOT.jar

My app will compile and run, but when I go to use the docx4j part, it gives me a NoClassDefFoundError,

Code: Select all
                                   java.lang.NoClassDefFoundError: Failed resolution of: Lcom/sun/istack/FinalArrayList;
                                                                               at ae.com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:197)
                                                                               at java.lang.reflect.Method.invoke(Native Method)
                                                                               at ae.javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:186)
                                                                               at ae.javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:146)
                                                                               at ae.javax.xml.bind.ContextFinder.find(ContextFinder.java:348)
                                                                               at ae.javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:446)
                                                                               at ae.javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:409)
                                                                               at org.docx4j.jaxb.NamespacePrefixMapperUtils.getPrefixMapper(NamespacePrefixMapperUtils.java:47)
                                                                               at org.docx4j.jaxb.Context.<clinit>(Context.java:67)


The line in my code that triggers this is

Code: Select all
ObjectFactory factory = Context.getWmlObjectFactory();


So it looks like the jaxb component is tied into a datatype that is only part of sun's java libraries. I am using ae-jaxb-2.2.5.jar, and I successfully resolved a previous ClassDefNotFound for log4j by installing that jar.

I attempted to see if any of the special dependencies for docx4j contained this sun FinalArrayList, but it doesn't appear that way. What should I do ?

Thanks

Re: docx4j-2.8.0-SNAPSHOT NoClassDefFoundError FinalArrayLis

PostPosted: Sun Mar 13, 2016 8:31 pm
by jason
In case you haven't found it, https://github.com/plutext/jaxb-2_2_5_1 ... .java#L196

says:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
FinalArrayList<Class> classes = new FinalArrayList<Class>();
Parsed in 0.014 seconds, using GeSHi 1.0.8.4


My original notes at http://www.docx4java.org/blog/2012/05/j ... n-android/ don't say anything about this.

But :-) in the dir https://github.com/plutext/AndroidDocxT ... aster/libs it is in
https://github.com/plutext/AndroidDocxT ... untime.jar

Note to self: when docx4j 3.3.0 is released (soon) that would be a good time to make a new Android version.

Re: docx4j-2.8.0-SNAPSHOT NoClassDefFoundError FinalArrayLis

PostPosted: Mon Mar 14, 2016 9:10 am
by digler99
Jason,

Thank you for the prompt reply. That solved my issue, as well as a few additional ones on the howto page. However, I'm stuck again with "No XmlSchema annotation found for org.docx4j.relationships"

Code: Select all
W/System.err: No XmlSchema annotation found for org.docx4j.relationships
.... repeats ~10 times
I/System.out: 343 [Thread-1404] ERROR org.docx4j.jaxb.NamespacePrefixMapperUtils  - name: com.sun.xml.internal.bind.namespacePrefixMapper value: org.docx4j.jaxb.NamespacePrefixMapperSunInternal@62a0c60 .. trying RI.
INFO org.docx4j.jaxb.NamespacePrefixMapperUtils  - Using NamespacePrefixMapper, which is suitable for the JAXB RI
INFO org.docx4j.jaxb.Context  - Using JAXB Reference Implementation
I/System.out: 372 [Thread-1404] INFO org.docx4j.jaxb.Context  - loading Context jc


I added the JAXBNamespacePrefixMapper-2.2.4.jar but it still gives me this error. I see that "org.docx4j.relationships" is in fact part of ae-docx4j-2.8.0-SNAPSHOT.jar, so I'm not really sure how to make the No XmlSchema error go away. http://stackoverflow.com/questions/14402287/equinox-java-lang-noclassdeffounderror/14402575#14402575 says to "import the javax.xml.bind" package to the manifest", but I do not know how to add multiple packages to a manifest.

Can you give me any guidance ?

Thanks


Here are all my dependencies
Code: Select all
compile files('libs/ae-docx4j-2.8.0-SNAPSHOT.jar')
    compile files('libs/activation.jar')
    compile files('libs/ae-jaxb-2.2.5.jar')
    compile files('libs/istack-commons-runtime.jar')
    compile files('libs/log4j-1.2.15.jar')
    compile files('libs/additionnal.jar')
    compile files('libs/jaxp-datatype.jar')
    compile files('libs/commons-logging-1.1.1.jar')
    compile files('libs/ae-xmlgraphics-commons.jar')
    compile files('libs/ae-awt.jar')
    compile files('libs/JAXBNamespacePrefixMapper-2.2.4.jar')


I appreciate any help you are able to supply.