java EAR 中的 WAR - jboss-deployment-structure.xml 被忽略
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26137219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WAR in EAR - jboss-deployment-structure.xml ignored
提问by Martin Baumgartner
My EAR consists out of an common-jar, an EJB-jar and a WAR. The WAR uses a spring context, so it is dependend on the spring-namespace description files in the META-INF direcotry.
我的 EAR 由一个 common-jar、一个 EJB-jar 和一个 WAR 组成。WAR 使用 spring 上下文,因此它依赖于 META-INF 目录中的 spring 命名空间描述文件。
My WAR/jboss-deployment-structure.xml contains
我的 WAR/jboss-deployment-structure.xml 包含
<module name="org.springfw">
<imports>
<include path="META-INF**" />
<include path="org**" />
</imports>
</module>
If i deploy the EAR and the WAR seperatly, the application works perfectly.
如果我单独部署 EAR 和 WAR,则该应用程序运行良好。
By deploying the same WAR inside of the EAR it fails with a ClassNotFoundException (org.spring...ContextLoaderListener).
通过在 EAR 内部署相同的 WAR,它会因 ClassNotFoundException (org.spring...ContextLoaderListener) 而失败。
Well, i edited my WAR/META-INF/Manifest.MF and added "Dependencies: org.springfw", the application fails on startup with:
好吧,我编辑了我的 WAR/META-INF/Manifest.MF 并添加了“依赖项:org.springfw”,应用程序在启动时失败:
Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
无法为 XML 架构命名空间找到 Spring NamespaceHandler [ http://www.springframework.org/schema/context]
This means the classes are available, but not the META-INF files.
这意味着类可用,但 META-INF 文件不可用。
To sum it up: If i deploy a WAR inside an EAR, i can still import modules via the Manifest of the WAR (works, but cant import the META-INF directory), but the WEB-INF/jboss-deployment-structure.xml will always be ignored.
总结一下:如果我在 EAR 中部署 WAR,我仍然可以通过 WAR 的清单导入模块(有效,但不能导入 META-INF 目录),但是 WEB-INF/jboss-deployment-structure。 xml 将始终被忽略。
EDIT:
编辑:
The module descriptor is
模块描述符是
<resource-root path="spring-context-3.2.10.RELEASE.jar">
<filter>
<include path="META-INF**" />
<include path="org**" />
</filter>
</resource-root>
回答by lazydev
Specify <sub-deployment>
in your deployment-structure.xml
.
指定<sub-deployment>
在你的deployment-structure.xml
。
And as said already, this xml should be in to top level ear meta-Inf.
正如已经说过的,这个 xml 应该在顶级耳朵元信息中。
<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>
See also jboss-deployment-structure.xml does not loads the dependencies in My EAR project
回答by eyesfree
Have you tried using module descriptor? https://docs.jboss.org/author/display/MODULES/Module+descriptors
您是否尝试过使用模块描述符?https://docs.jboss.org/author/display/MODULES/Module+descriptors