将docx4j库与jboss 7一起使用 [英] Use docx4j library with jboss 7
问题描述
我尝试使用pptx4j库生成一个pptx.我可以成功生成一个pptx.然后,我将代码应用于在jboss 7服务器上运行的大型项目.项目已成功部署在服务器上.但是,当我尝试运行该应用程序时,会出现以下异常.
I try to generate a pptx using pptx4j library. I could generate a pptx successfully. Then I applied the code to a huge project that run on the jboss 7 server. Project is sucessfully deployed on the server. But when I'm trying to run the application it gives following exception.
java.lang.NoClassDefFoundError:com/sun/xml/internal/bind/marshaller/NamespacePrefixMapper
java.lang.NoClassDefFoundError: com/sun/xml/internal/bind/marshaller/NamespacePrefixMapper
该异常发生在代码的下一行.
That exception is occurred for following line in the code.
PresentationMLPackage presentationMLPackage = PresentationMLPackage
.createPackage();
在jboss 7服务器上是否有一种特殊的方式来运行docx4j库.我在互联网上搜索了更多内容,但找不到解决方案.
Is there a special way run docx4j library on the jboss 7 server. I searched more on Internet but I couldn't find a solution.
推荐答案
JBoss AS 7引入了模块(捆绑)的概念,该概念极大地改变了类的加载方式.您应该熟悉这个概念:
JBoss AS 7 introduced the concept of modules (bundles) which drastically changed how classes get loaded. You should get yourself familiar with this concept:
https://docs.jboss.org/author/display/AS71/Class + Loading + in + AS7
jboss-deployment-structure.xml是JBoss特定的部署描述符,可用于以细粒度方式控制类加载.应将其放在META-INF(或用于Web部署的WEB-INF)的顶级部署中.它可以执行以下操作:
jboss-deployment-structure.xml is a JBoss specific deployment descriptor that can be used to control class loading in a fine grained manner. It should be placed in the top level deployment, in META-INF (or WEB-INF for web deployments). It can do the following:
- 防止自动依赖项被添加
- 添加其他依赖项
- 定义其他模块
- 更改EAR部署的隔离类加载行为
- 将其他资源根添加到模块中
当您在JBoss AS 7中收到 NoClassDefFoundError
时,您可以打赌您某个地方缺少依赖项.对于您的特定情况,您需要添加对模块 com.sun.xml.bind
的依赖.
When you get a NoClassDefFoundError
in JBoss AS 7 you can bet that you have a missing dependency somewhere. As for your specific case, you need to add a dependency on module com.sun.xml.bind
.
docx4j
甚至还有一个页面:
http://www.docx4java.org/forums/jboss-f29/jboss-7-config-t1678.html
要使docx4j在您的WAR中工作,您只需要包含WEB-INF/jboss-deployment-structure.xml,其中包含:
to get docx4j working in your WAR, you just need to include WEB-INF/jboss-deployment-structure.xml containing:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<dependencies>
<module name="com.sun.xml.bind" />
</dependencies>
</deployment>
</jboss-deployment-structure>
这篇关于将docx4j库与jboss 7一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!