I was able to successfully create a simple project with docx4j ( http://www.docx4java.org ). This simple project successfully created and wrote on a .docx document. Now I
I assume you are using Java 7. I was able to solve this issue with JBoss EAP 6.2 running on
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1~0.13.10.1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
Define following JBoss module:
<!-- module.xml content --> <module xmlns="urn:jboss:module:1.1" name="org.docx4j-compat"> <dependencies> <module name="sun.jdk"/> <system export="true"> <paths> <path name="com/sun/xml/internal/bind/marshaller"/> </paths> </system> </dependencies> </module>
Add dependency on this module to your WEB-INF/jboss-deployment-structure.xml.
Please have a look at the docx4j JBOSS deployment forum
For example, from one of the posts:
version of my Serializer and Xalan jars. I had 2.7.1 for each as instructed, but my App Server (JBoss 5.1.0) had different versions (un-numbered: serializer.jar and xalan.jar) in the root lib/endorsed folder which was overriding these. When i replaced these jars with the 2.7.1 versions it worked perfectly.
Please let us know if the suggestions there work for you, or not.
In Maven pom.xml place these missing dependencies and the problem was solved (on JBoss 7.1.3)
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.7</version>
</dependency>
<dependency>
<groupId>com.googlecode.jaxb-namespaceprefixmapper-interfaces</groupId>
<artifactId>JAXBNamespacePrefixMapper</artifactId>
<version>2.2.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
JBoss AS7 has a class loading mechanism which is different from previous versions. See generally https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7
It includes a module named javax.xml.bind.api; to get docx4j working in your WAR, you just need to include WEB-INF/jboss-deployment-structure.xml containing:
<deployment>
<dependencies>
<module name="com.sun.xml.bind" />
</dependencies>
</deployment>
Details/discussion
modules\javax\xml\bind\api\main says:
<dependencies>
<module name="javax.activation.api" export="true"/>
<module name="javax.xml.stream.api"/>
<module name="com.sun.xml.bind" services="import"/>
<module name="javax.api"/>
</dependencies>
<resources>
<resource-root path="jboss-jaxb-api_2.2_spec-1.0.3.Final.jar"/>
<!-- Insert resources here -->
</resources>
modules\com\sun\xml\bind\main says:
<resources>
<resource-root path="jaxb-impl-2.2.4.jar"/>
<resource-root path="jaxb-xjc-2.2.4.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api" />
<module name="javax.xml.bind.api" />
<module name="javax.xml.stream.api" />
</dependencies>
so you might think the following would also work:
<deployment>
<dependencies>
<module name="javax.xml.bind.api" />
</dependencies>
</deployment>
but it didn't seem to, perhaps because is given effect?
So after some research we find the solution for docx4j will work on jboss
u need to define new module in the jboss lets call it org.docx4j-compat
and it will be at \system\layers\base\org
now add all the relevant jars to the main folder and the module.xml
the module.xml :
<resources>
<resource-root path="docx4j-3.1.0.jar"/>
<resource-root path="docx4j-ImportXHTML-3.0.1.jar"/>
<resource-root path="jaxb-api-2.1.jar"/>
<resource-root path="jaxb-svg11-1.0.2.jar"/>
<resource-root path="jaxb-xmldsig-core-1.0.0.jar"/>
<resource-root path="jaxb-xslfo-1.0.1.jar"/>
</resources>
<dependencies>
<module name="org.slf4j"/>
<module name="org.apache.commons.io"/>
<module name="sun.jdk"/>
<system export="true">
<paths>
<path name="com/sun/xml/internal/bind/marshaller"/>
</paths>
</system>
<module name="javax.xml.bind.api"/>
<module name="javax.api"/>
<module name="com.sun.xml.bind" />
</dependencies>
hope it was helpful :)
Those tow minimal steps worked for me (JBOSS 7.1.3, DOCX4J 3.2.2):
WEB-INF\jboss-deployment-structure.xml
file
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<dependencies>
<module name="com.sun.xml.bind" />
</dependencies>
</deployment>
</jboss-deployment-structure>
<dependency>
<groupId>com.googlecode.jaxb-namespaceprefixmapper-interfaces</groupId>
<artifactId>JAXBNamespacePrefixMapper</artifactId>
<version>2.2.4</version>
<scope>runtime</scope>
</dependency>