这就是我想要实现的目标:
-
1 ear-package:all.ear
-
耳包含有两个战争(A.war,B.war在耳根)
-
耳包包含1个自制的 jar C和许多第三方 jar (在APP-INF \ lib下)
这个包需要部署在JBoss WildFly 8.2.1上
我正在使用maven的耳塞(maven-ear-plugin,版本2.10.1) . 我在pom中的配置看起来像这样(这是'parent'项目,它结合了其他三个项目):
<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"
当我将每个库放在root下(不要使用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设置?...?)
1 回答
根据JAVA EE规范,容器不会扫描包含在耳朵库目录中的任何jar的任何部署描述符 .
但我认为你想要做的是从WARs访问你在C.jar中声明的那些ejb . 同样,根据规格,任何其他模块都可以看到坐在耳朵里的任何ejb-jar:
所以,只需将C.jar放在lib目录中的任何其他位置,你就可以了 .