这就是我想要实现的目标:
- 1个耳包:all.ear
- ear-package 包含两个war的(A.war,B.war在ear的根)
- ear-package包含1个自制jar C和大量第三方jar(APP-INF\lib下)
这个包需要部署在 JBoss WildFly 8.2.1 上
我正在使用 maven 的 ear 插件(maven-ear-plugin,版本 2.10.1)。我在 pom 中的配置如下所示(这是结合了其他三个项目的“父”项目):
<configuration>
<finalName>All</finalName>
<defaultLibBundleDir>APP-INF/lib</defaultLibBundleDir>
<includeLibInApplicationXml>true</includeLibInApplicationXml>
<version>6</version>
<displayName>All</displayName>
<modules>
<jarModule>
<groupId>project</groupId>
<artifactId>C</artifactId>
<bundleFileName>C.jar</bundleFileName>
<uri>APP-INF/lib/C.jar</uri>
<bundleDir>APP-INF/lib</bundleDir>
</jarModule>
<webModule>
<groupId>project</groupId>
<artifactId>A</artifactId>
<uri>A.war</uri>
<bundleFileName>A.war</bundleFileName>
<contextRoot>/a</contextRoot>
<bundleDir>/</bundleDir>
</webModule>
<webModule>
<groupId>project</groupId>
<artifactId>B</artifactId>
<uri>B.war</uri>
<bundleFileName>B.war</bundleFileName>
<contextRoot>/b</contextRoot>
<bundleDir>/</bundleDir>
</webModule>
</modules>
<archive>
<manifestEntries>
<Implementation-Version>1.0</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
我的 META.INF/application.xml 文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="6"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_6.xsd">
<display-name>All</display-name>
<initialize-in-order>true</initialize-in-order>
<module>
<java>APP-INF/lib/C.jar</java>
</module>
<module>
<web>
<web-uri>B.war</web-uri>
<context-root>b</context-root>
</web>
</module>
<module>
<web>
<web-uri>A.war</web-uri>
<context-root>a</context-root>
</web>
</module>
<library-directory>APP-INF/lib</library-directory>
</application>
耳包制作完成。所有第三方jar都在APP-INF/lib下,但是C.jar在根目录下。
在尝试将包上传到 JBoss 时,我遇到了很多问题并遇到了不同的错误:
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS016703: Module may not be a child of the EAR's library directory. Library directory: APP-INF/lib, module file name: APP-INF/lib/[SomeThirthPartyLib].jar"
当我将每个库都放在根目录下时(不要使用 APP-INF),我得到了 B.war 的 ClassNotFoundError(无法从 C.jar 中找到类)。
我已经尝试将“jboss”标签添加到 maven-ear-plugin(配置),但 JBoss 8+ 不支持这些标签。
我想要一个 .ear 包,它可以部署在 JBoss 中,包含 2 个战争和 1 个 jar,这两个战争都引用了它。
我错过了什么?(具体的 Manifest 配置?针对 A、B 或 C 的具体 pom.xml 设置?JBoss 设置?...?)