我的耳结构如下:
XYZ.ear
|
|------------- lib
|-------------META-INF
|--------------firstEJB.jar
|--------------app.war
当我尝试部署XYZ.ear时,我无法访问firstEJB.jar中的类。我在尝试部署时遇到了followint错误:
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中的一个类。
当我尝试在lib目录中添加firstEJB.jar时,它显示了一些beanmanager相关的问题,因为它包含ejbs。所以我试着把这个jar放在lib目录之后,经过这个链接:
https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly
我正在使用build.gradle来构建EAR.My build.gradle是:
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");
}
}
我在META-INF中的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 \ wildfly8.0.0.Final \ bin目录
ERROR com.sial.ecommerce.core.init.DeepInit - C:\Apps\wildfly-8.0.0.Final\bin\src\test\resources\xml\con\con.json (The system cannot find the path specified)
DEEPInit类是myfirstEJB.jar中的一个类。
而不是
C:\ Apps \ wildfly-8.0.0.Final \ standalone \ deploments目录(我们的耳朵在哪里)。
有人可以帮我构建和部署合适的耳朵,以便可以访问firstEJB.jar中的类吗?
答案 0 :(得分:0)
尝试将wildfly配置中EE子系统的“ear-subdeployments-isolated”属性设置为false:
<subsystem xmlns="urn:jboss:domain:ee:1.0" >
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
</subsystem>
如果此设置设置为true(默认值为afaik),那么您必须声明从战争到jar的依赖关系:
https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly
答案 1 :(得分:0)
看起来像com.sial.ecommerce.core.init.DeepInit类尝试使用以下代码读取本地资源:
new File(".\src\test\resources\xml\con\con.json");
如果是,请将此代码替换为:
com.sial.ecommerce.core.init.DeepInit.getResource("xml\con\con.json");