Page 1 of 1

Failed to deploy Docx4j app to JBoss EAP 6.2 :/

PostPosted: Thu Nov 28, 2013 11:49 pm
by cronicz
Hey there,

recently I tried to deploy my application, which utilizes docx4j, to a JBoss 6.2 EAP Server. Unfortunately the process of generating docx documents does not work anymore on EAP 6.2 though everything is fine on JBoss 7.1.1.

A few exceptions that caught my attention:

Code: Select all
Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper from [Module "deployment.ProfilerApp.ear:main" from Service Module Loader]
   at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:197) [jboss-modules.jar:1.3.0.Final-redhat-2]
   at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:443) [jboss-modules.jar:1.3.0.Final-redhat-2]
   at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:431) [jboss-modules.jar:1.3.0.Final-redhat-2]
   at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:373) [jboss-modules.jar:1.3.0.Final-redhat-2]
   at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:118) [jboss-modules.jar:1.3.0.Final-redhat-2]


Code: Select all
Caused by: java.lang.NoClassDefFoundError: com/sun/xml/internal/bind/marshaller/NamespacePrefixMapper
   at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.7.0_45]
   at java.lang.ClassLoader.defineClass(ClassLoader.java:800) [rt.jar:1.7.0_45]
   at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:345) [jboss-modules.jar:1.3.0.Final-redhat-2]
   at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:423) [jboss-modules.jar:1.3.0.Final-redhat-2]


Code: Select all
13:41:23,345 WARN  [org.jboss.modules] (http-/127.0.0.1:8080-2) Failed to define class org.docx4j.jaxb.NamespacePrefixMapperSunInternal in Module "deployment.ProfilerApp.ear:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/docx4j/jaxb/NamespacePrefixMapperSunInternal (Module "deployment.ProfilerApp.ear:main" from Service Module Loader)
   at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:428) [jboss-modules.jar:1.3.0.Final-redhat-2]
   at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:261) [jboss-modules.jar:1.3.0.Final-redhat-2]
   at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:76) [jboss-modules.jar:1.3.0.Final-redhat-2]


The errors are thrown while executing the following line of code:

Code: Select all
WordprocessingMLPackage wml = WordprocessingMLPackage.load(new File("template.docx"));


In my pom.xml I added the following dependency:

Code: Select all
<dependency>
  <groupId>org.docx4j</groupId>
  <artifactId>docx4j</artifactId>
  <version>3.0.0</version>
</dependency>


Any idea what needs to be changed? Any help is highly appreciated! Thanks in advance :)

Re: Failed to deploy Docx4j app to JBoss EAP 6.2 :/

PostPosted: Fri Nov 29, 2013 10:58 am
by thezed
Your issue may be with JBoss modules not giving the docx4j code access to the com.sun.xml.bind classes.

In the module you have your docx4j jar file defined in, add the following dependency to module.xml:

Code: Select all
<dependencies>
    ...
    ...
    <module name="com.sun.xml.bind" />
</dependencies>


I had a similar issue.

Note you will most likely still get some ClassNotFoundException warnings from the JBoss class loaders because they can't find com.sun.xml.internal.*, but docx4j should then fall back to using com.sun.xml.bind and work okay.

Re: Failed to deploy Docx4j app to JBoss EAP 6.2 :/

PostPosted: Mon Jan 20, 2014 8:24 pm
by asyal
Hi thezed

I am facing a similar issue. I am using jboss 7.1.1 with docx4j 2.8.1. Either i end up getting NoClassDefFoundError for Context.java class or
java.util.NoSuchElementException
at java.util.Collections$EmptySet$1.next(Collections.java:2912) [rt.jar:1.6.0_31]
at java.util.Collections$1.nextElement(Collections.java:3389) [rt.jar:1.6.0_31]
at org.docx4j.utils.Log4jConfigurator.configure(Log4jConfigurator.java:42) [docx4j-2.8.1.jar:]
at org.docx4j.jaxb.Context.<clinit>(Context.java:51) [docx4j-2.8.1.jar:]

Could you plz help me in this regards? This is what i have tried so far
!) Putting all the docx4j jars in the standalone\deployment folder
2) creating jboss-deployment-structure.xml as indicated in this forum

but i have not tried what you mentioned , like creating modules etc. Could you please elaborate on this ? Three are so many jar files related to docx4j. Do we go ahead and create modules for each one of them or what?

Any help in this regard is very appreciable.

Thanks

Re: Failed to deploy Docx4j app to JBoss EAP 6.2 :/

PostPosted: Tue Jan 21, 2014 7:44 am
by jason
asyal wrote:Either i end up getting NoClassDefFoundError for Context.java class or
java.util.NoSuchElementException


Well the NoSuchElementException is better than NoClassDefFoundError for Context.java, since at least in this case you have successfully got docx4j on your classpath. That error is related to log4j configuration. Either fix it, or you could use docx4j 3.0 instead, which doesn't have Log4jConfigurator anymore.

Re: Failed to deploy Docx4j app to JBoss EAP 6.2 :/

PostPosted: Sat Aug 09, 2014 8:22 am
by melgacorm
Hi there.

I have the exactly same issue.
I'm trying to use docx4j version 3.0.1 in jboss EAP 6.2. Getting the same stack.

I already tried do add <module name="com.sun.xml.bind" /> to the dependencies in my jboss-deployment-structure.xml, but it had no effect.

It works fine in Tomcat.

Any other hint?

Thanks. Regards,

Rodrigo