我的 EAR 由一个 common-jar、一个 EJB-jar 和一个 WAR 组成。 WAR 使用 spring 上下文,因此它依赖于 META-INF 目录中的 spring-namespace 描述文件。
我的WAR/jboss-deployment-structure.xml包含
<module name="org.springfw">
<imports>
<include path="META-INF**" />
<include path="org**" />
</imports>
</module>
如果我分别部署 EAR 和 WAR,应用程序将完美运行。
通过在 EAR 中部署相同的 WAR,它会失败并出现 ClassNotFoundException (org.spring...ContextLoaderListener)。
好吧,我编辑了我的 WAR/META-INF/Manifest.MF 并添加了“Dependencies: org.springfw”,应用程序在启动时失败:
Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
这意味着类可用,但 META-INF 文件不可用。
总结一下:如果我在 EAR 中部署 WAR,我仍然可以通过 WAR 的 list 导入模块(有效,但不能导入 META-INF 目录),但是 WEB-INF/jboss-deployment -structure.xml 将始终被忽略。
编辑:
模块描述符是
<resource-root path="spring-context-3.2.10.RELEASE.jar">
<filter>
<include path="META-INF**" />
<include path="org**" />
</filter>
</resource-root>
最佳答案
指定 <sub-deployment>
在你的deployment-structure.xml
.
如前所述,这个 xml 应该在顶级 ear meta-Inf 中。
<jboss-deployment-structure>
<sub-deployment name="myapp.war">
<dependencies>
<module name="org.javassist" export="true" />
<module name="org.apache" export="true"/>
<module name="org.antlr" export="true"/>
<module name="org.dom4j" export="true"/>
<module name="org.apache" export="true"/>
<module name="org.hibernate" export="true"/>
</dependencies>
</sub-deployment>
另见 jboss-deployment-structure.xml does not loads the dependencies in My EAR project
关于java - EAR 中的 WAR - 忽略 jboss-deployment-structure.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26137219/