我正在使用build.gradle来构建EAR。
buildscript
{
repositories
{
mavenCentral();
maven{url "https://repository.jboss.org/nexus/content/repositories/releases/"}
}
configurations
{
compile
testCompile
testRuntime
jacoco
}
dependencies{classpath 'org.ajoberstar:gradle-jacoco:0.3.0'}
}
allprojects
{
group='com.sial.ecommerce'
version=''
repositories
{
mavenCentral();
maven{url"https://repository.jboss.org/nexus/content/repositories/releases/"}
}
apply plugin:'java'
apply plugin:'jacoco';
apply plugin: 'ear'
dependencies
{
deploy project(path:':app', configuration: 'archives');
deploy project(path:':firstEJB', configuration: 'archives');
}
ear
{
version = "";
archiveName ="XYZ.ear";
appDirName 'EarContent'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE;
caseSensitive = true;
rootSpec.exclude("**/activation-1.1.jar");
rootSpec.exclude("**/asm*.jar");
rootSpec.exclude("**/jboss-*.jar");
rootSpec.exclude("**/org.jacoco*.jar");
rootSpec.exclude("**/wildfly-*.jar");
rootSpec.exclude("**/hibernate-*.jar");
rootSpec.exclude("**/gradle-*.jar");
rootSpec.exclude("**/cdi-*.jar");
rootSpec.exclude("**/org.osgi.*.jar");
rootSpec.exclude("**/serializer-*.jar");
rootSpec.exclude("**/arquillian-*.jar");
rootSpec.exclude("**/resteasy-*.jar");
rootSpec.exclude("**/guava-*.jar");
rootSpec.exclude("**/jackson-jaxrs-*.jar");
rootSpec.exclude("**/jackson-core-asl-*.jar");
rootSpec.exclude("**/jackson-mapper-asl-*.jar");
rootSpec.exclude("**/reflections-*.jar");
rootSpec.exclude("**/metrics-core-*.jar");
rootSpec.exclude("**/servo-core-*.jar");
rootSpec.exclude("**/aspectjweaver-*.jar");
rootSpec.exclude("**/javax.json-*.jar");
rootSpec.exclude("**/jaxrs-api-*.jar");
rootSpec.exclude("**/javax.mail-*.jar");
rootSpec.exclude("**/validation-api-*.jar");
rootSpec.exclude("**/javassist-*.jar");
rootSpec.exclude("**/dom4j-*.jar");
rootSpec.exclude("**/annotations-*.jar");
rootSpec.exclude("**/javax.inject-*.jar");
rootSpec.exclude("**/xalan-*.jar");
rootSpec.exclude("**/el-api-*.jar");
rootSpec.exclude("**/jsr250-api-*.jar");
rootSpec.exclude("**/xml-apis-*.jar");
rootSpec.exclude("**/slf4j-api-1.7.6.jar");
}
}
其构建结构:
XYZ.ear
|
|------------- lib
|-------------META-INF
|--------------firstEJB.jar
|--------------app.war
当我尝试部署时,无法接收firstEJB.jar中的类。
我收到了一个错误:
15:49:24,583 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC000001: Failed to start service jboss.deployment.subunit."XYZ.ear"."app.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."XYZ.ear"."app.war".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of subdeployment "app.war" of deployment "XYZ.ear"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_71]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_71]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: java.lang.ClassNotFoundException: com.sial.ecommerce.core.init.DeepInit from [Module "deployment.XYZ.ear.app.war:main" from Service Module Loader]
at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.checkDeclaredApplicationClassAsServlet(JaxrsScanningProcessor.java:292)
at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scanWebDeployment(JaxrsScanningProcessor.java:154)
at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.deploy(JaxrsScanningProcessor.java:105)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
... 5 more
Caused by: java.lang.ClassNotFoundException: com.sial.ecommerce.core.init.DeepInit from [Module "deployment.XYZ.ear.app.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.checkDeclaredApplicationClassAsServlet(JaxrsScanningProcessor.java:290)
DeepInit类位于firstEJB.jar
中当我在调试模式下启动Wildfly服务器并尝试调试时,我发现找到该类的目录与预期的不同。
它看起来:
C:/Apps/wildfly-8.0.0.Final/bin/content/XYZ.ear/lib
无效。
预期目录是:
C:/Apps/wildfly-8.0.0.Final/standalone/deployments/XYZ.ear
在使用爆炸方法进行部署时(即右键单击并在wildfly服务器中添加项目),它可以正常工作。
application.xml如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" id="Application_ID" version="7">
<display-name>ABC</display-name>
<module>
<web>
<web-uri>app.war</web-uri>
<context-root>app</context-root>
</web>
</module>
<module><ejb>myfirstEJB.jar</ejb></module>
</application>
我想知道如何使用“C:/Apps/wildfly-8.0.0.Final/bin/content/XYZ.ear/lib”,因为我没有在任何地方设置它。
有人可以帮我找到一种方法将目录更改为
C:/Apps/wildfly-8.0.0.Final/standalone/deployments/XYZ.ear
所以我可以访问firstEJB.jar中的类吗?