Page 1 of 1

Grails and docx4j v2.6.0

PostPosted: Thu Dec 02, 2010 1:10 pm
by pkcinna
It appears docx4j.2.5.0 is compatible with Grails (v1.3.5) but docx4j.2.6.0 is not. marshaling to a string fails when I change the Grails conf/BuildConfig to use 2.6.0. JAXB makes me dizzy with all its "features" so I was hoping someone can assist. I switched to jdk 1.6 to simplify JAXB situation but still can't get around this error.

Document wmlDocumentEl = (org.docx4j.wml.Document) documentPart.getJaxbElement();
String xml = XmlUtils.marshaltoString(wmlDocumentEl, true);


JAXB: RI not present. Trying Java 6 implementation.
JAXB: Using Java 6 implementation.
jaxb.NamespacePrefixMapperUtils javax.xml.bind.PropertyException: property "com.sun.xml.internal.bind.namespacePrefixMapper" must be an instance of type com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper, not org.docx4j.jaxb.NamespacePrefixMapperSunInternal
javax.xml.bind.PropertyException: property "com.sun.xml.internal.bind.namespacePrefixMapper" must be an instance of type com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper, not org.docx4j.jaxb.NamespacePrefixMapperSunInternal
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.setProperty(MarshallerImpl.java:501)
at org.docx4j.jaxb.NamespacePrefixMapperUtils.setProperty(NamespacePrefixMapperUtils.java:102)
at org.docx4j.XmlUtils.marshaltoString(XmlUtils.java:379)

Re: Grails and docx4j v2.6.0

PostPosted: Thu Dec 02, 2010 3:37 pm
by jason
property "com.sun.xml.internal.bind.namespacePrefixMapper" must be an instance of type com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper, not org.docx4j.jaxb.NamespacePrefixMapperSunInternal


is an odd error, because

Code: Select all
class NamespacePrefixMapperSunInternal extends com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper


Could you please post the output of

Code: Select all
java -version


and I will try to reproduce.

Re: Grails and docx4j v2.6.0

PostPosted: Fri Dec 03, 2010 1:51 pm
by pkcinna
It is working after trying Tomcat and several jdk 1.6 versions on windows and CentOS. The issue only appears if I am deploying from SpringSource Tool Suite v2.5.1 (Eclipse).

These both work:

Code: Select all
D:\Program Files\Java>jdk1.6.0_22\bin\java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)

[pkcinna@ip-97-74-121-232 ~]$ /opt/jdk/bin/java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Client VM (build 17.0-b16, mixed mode, sharing)


Thanks!

Re: Grails and docx4j v2.6.0

PostPosted: Fri Dec 03, 2010 2:53 pm
by pkcinna
To be more specific about the issue, it appears to only happen when starting tomcat using "grails run-app". If I create a war file and deploy it to tomcat, there is no problem.

So this does seem to be a specific issue with grails 1.3.5 and docx4j 2.6.0 but it is specific to grails and tomcat when using "grails run-app".

Any ideas?

Re: Grails and docx4j v2.6.0

PostPosted: Thu Dec 23, 2010 2:45 pm
by Julienoune
Hello all,

I have the same issue. My env is :
grails 1.3.4
docx 2.6.0
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)

Running on Windows XP throught the following command line
grails -Dserver.port = 8080 run-app

Any idea about this issue?

Re: Grails and docx4j v2.6.0

PostPosted: Fri Mar 04, 2011 10:27 am
by kjetilhp
anyone solved this? getting some of the same behavior when using mvn jetty:run and loading a document inside a webapp...

the exact same code works fine during unit tests right before so suspect it has something to do with classloading...

Code: Select all
:java.lang.RuntimeException: javax.xml.bind.PropertyException: property "com.sun.xml.internal.bind.namespacePrefixMapper" must be an instance of type com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper, not org.docx4j.jaxb.NamespacePrefixMapperSunInternal


JAXB: RI not present. Trying Java 6 implementation.
JAXB: Using Java 6 implementation.
2011-03-03 23:13:40.875:INFO :Context :loading Context jc
2011-03-03 23:13:47.910:INFO :Context :loaded com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl .. loading others ..
2011-03-03 23:13:48.880:INFO :Context :.. others loaded ..
2011-03-03 23:13:48.898:WARN :XmlUtils :Using default SAXParserFactory: null
2011-03-03 23:13:48.903:ERROR:amespacePrefixMapperUtils:javax.xml.bind.PropertyException: property "com.sun.xml.internal.bind.namespacePrefixMapper" must be an instance of type com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper, not org.docx4j.jaxb.NamespacePrefixMapperSunInternal
2011-03-03 23:13:48.904:ERROR:ContentTypeManager :java.lang.RuntimeException: javax.xml.bind.PropertyException: property "com.sun.xml.internal.bind.namespacePrefixMapper" must be an instance of type com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper, not org.docx4j.jaxb.NamespacePrefixMapperSunInternal
2011-03-03 23:13:48.905:ERROR:DocxMerger :Loading of document from database failed
org.docx4j.openpackaging.exceptions.InvalidFormatException: Bad [Content_Types].xml
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:657)
at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:200)
at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:189)


Caused by: java.lang.RuntimeException: javax.xml.bind.PropertyException: property "com.sun.xml.internal.bind.namespacePrefixMapper" must be an instance of type com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper, not org.docx4j.jaxb.NamespacePrefixMapperSunInternal
at org.docx4j.XmlUtils.marshaltoString(XmlUtils.java:429)
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:636)
... 60 more
Caused by: javax.xml.bind.PropertyException: property "com.sun.xml.internal.bind.namespacePrefixMapper" must be an instance of type com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper, not org.docx4j.jaxb.NamespacePrefixMapperSunInternal
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.setProperty(MarshallerImpl.java:501)
at org.docx4j.jaxb.NamespacePrefixMapperUtils.setProperty(NamespacePrefixMapperUtils.java:102)
at org.docx4j.XmlUtils.marshaltoString(XmlUtils.java:390)
... 61 more


Re: Grails and docx4j v2.6.0

PostPosted: Fri Mar 04, 2011 11:14 pm
by jason
Does removing the following from your class path help?

Code: Select all
      <dependency>
            <groupId>com.sun.xml</groupId>
            <artifactId>jaxb-NamespacePrefixMapper-interfaces</artifactId>
            <version>2.0.0</version>                
         </dependency>

Re: Grails and docx4j v2.6.0

PostPosted: Fri Mar 04, 2011 11:25 pm
by kjetilhp
Just tested with standalone Jetty 7 also before your post and that has similar issues... Tomcat however works out of the box.

Removing that liberary does the trick, both on jetty:run and Jetty standalone. So I guess this is classloading related since Jetty and Tomcat has different ways of loading the libs in a webapp...

Thanks for the answer though, this should be noted somewhere :)