为了向多个应用程序显示外部jar,我通常将外部jar放在JBOSS 5.x的$ JBOSS_HOME / server / default / lib directoy中。这些jar在AS的startp处自动启动。 我将如何在wildfly-9.0.2.Final中做。
@Sam Thankx回复 但我仍然得到错误,请看我的方案如下 结构
在test.jar中有EJB3会话bean java类。在这个类中有import stmt as。
import com.oracle.asmc.ejb3.statelesssession.SLE3DecryptLocal;
注意 - 上面的testclient.jar不是test.ear的一部分。(我想从多个EAR访问这个testclient.jar)
要部署test.ear,我已完成以下步骤
我在jboss-deployment-structure.xml中添加了以下配置,并在创建test.ear时放置在META-INF目录中。
<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<dependencies>
<module name="testclient" />
</dependencies>
</deployment>
</jboss-deployment-structure>
为了部署Test.ear应用程序,访问了“http://127.0.0.1:9990/”并进行了travesed链接Deployments - &gt;添加 - &gt;添加部署---&gt;完成 但仍然有以下错误。
12:19:22,439 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0027: Starting deployment of "test.ear" (runtime-name: "test.ear")
12:19:22,602 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0207: Starting subdeployment (runtime-name: "test.jar")
12:19:22,608 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0207: Starting subdeployment (runtime-name: "test.war")
12:19:23,524 INFO [org.jboss.weld.deployer] (MSC service thread 1-2) WFLYWELD0003: Processing weld deployment test.ear
12:19:23,631 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-2) HV000001: Hibernate Validator 5.1.3.Final
12:19:23,842 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.subunit."test.ear"."test.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."test.ear"."test.jar".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment "test.jar" of deployment "test.ear"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:163)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class com.oracle.test.SlsTestBean with ClassLoader ModuleClassLoader for Module "deployment.test.ear.test.jar:main" from Service Module Loader
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70)
at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:57)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.handleAnnotations(InterceptorAnnotationProcessor.java:107)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:92)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:77)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:156)
... 5 more
Caused by: java.lang.NoClassDefFoundError: com/oracle/asmc/ejb3/statelesssession/SLE3DecryptLocal
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:65)
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)
... 10 more
Caused by: java.lang.ClassNotFoundException: com/oracle/asmc/ejb3/statelesssession/SLE3DecryptLocal from [Module "deployment.test.ear.test.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130)
... 15 more
@Sam thankx回复
我在test.jar的META-INF中添加了'jboss-deployment-structure.xml'。
注意 - 是的,我正在从test.jar访问'com / oracle / asmc / ejb3 / statelesssession / SLE3DecryptLocal'(存在于testclient.jar模块中)。
现在我的test.ear包含
META-INF / application.xml中
test.war
test.jar(此test.jar的META-INF目录中存在'jboss-deployment-structure.xml')
但我仍然遇到以下错误。
Caused by: java.lang.NoClassDefFoundError: com.oracle.asmc.ejb3.statelesssession.SLE3DecryptLocal
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:65)
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)
... 10 more
Caused by: java.lang.ClassNotFoundException: com.oracle.asmc.ejb3.statelesssession.SLE3DecryptLocal from [Module "deployment.test.ear.test.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130)
... 15 more
答案 0 :(得分:4)
使用WildFly完全改变了类加载。您可以阅读[at]
的更多信息上找到更多信息从WildFly 8开始,类加载与以前版本的JBoss AS有很大不同。类加载基于JBoss Modules项目。 WildFly的类加载不是更熟悉的分层类加载环境,而是基于必须在其他模块上定义显式依赖关系的模块。 WildFly中的部署也是模块,除非定义了对这些类的显式依赖,否则无法访问应用程序服务器中jar中定义的类。
基本上,您可以使用共享库添加模块,并使部署依赖于它。
例如,您可以使用jboss-cli(位于bin文件夹中)添加带有MySQL Connector Java的模块
module add --name=org.mysql --resources=mysql-connector-java-5.1.31-bin.jar --dependencies=javax.api,javax.transaction.api
然后,为了让您的应用程序看到它,您可以添加一个名为jboss-deployment-structure.xml
的文件,其中包含以下信息:
<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<dependencies>
<module name="org.mysql" />
</dependencies>
</deployment>
</jboss-deployment-structure>
模块名称必须与您在模块添加命令中指定的名称匹配。
如果您在jboss-deployment-structure.xml
部分的MANIFEST.MF
中添加模块名称,则可以省略文件Dependencies