在 wildfly-9.0 中部署第三方 jar。2.Final

Deployment of third party jar in wildfly-9.0.2.Final

为了让多个应用程序看到外部罐子,我通常将外部罐子放在 JBOSS 中的 $JBOSS_HOME/server/default/lib 目录中 5.x.These 罐子在 AS 启动时自动启动。 我将如何在 wildfly-9.0.2.Final.

中执行此操作

@Sam 谢谢回复 但我仍然遇到错误,请看我的场景如下 结构

  1. 在 test.ear
  2. 中存在名为 test.jar 的 jar 存档
  3. 在 test.jar 中有 EJB3 会话 bean java class。在这个 class 中有 import stmt as.

    导入com.oracle.asmc.ejb3.statelesssession.SLE3DecryptLocal;

  4. 以上包 'com.oracle.asmc.ejb3.statelesssession.SLE3DecryptLocal' 存在于 testclient.jar

注意 - 以上 testclient.jar 不是 test.ear 的一部分。(我想从多个 EAR 访问这个 testclient.jar)

要部署 test.ear,我已完成以下步骤

  1. ./jboss-cli.sh -c(存在于 bin 目录中)
  2. 模块添加 --name=testclient --resources=~/client_jar/testclient.jar
  3. 我在 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>
    
  4. 为了部署 Test.ear 应用程序,访问“http://127.0.0.1:9990/”并遍历 link 部署 --> 添加 --> 添加部署 --->完成 但是仍然出现以下错误。

    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 谢谢回复

我在 test.jar 的 META-INF 中添加了 'jboss-deployment-structure.xml'。

注意 - 是的,我正在从 test.jar.

访问 'com/oracle/asmc/ejb3/statelesssession/SLE3DecryptLocal'(存在于 testclient.jar 模块中)

现在我的 test.ear 包含

  1. META-INF/application.xml

  2. test.war

  3. test.jar('jboss-deployment-structure.xml' 存在于此 test.jar 的 META-INF 目录中)

但我仍然遇到以下错误。

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

Class WildFly 加载已完全改变。您可以在 [at]

阅读更多信息

Since WildFly 8, Class loading is considerably different to previous versions of JBoss AS. Class loading is based on the JBoss Modules project. Instead of the more familiar hierarchical class loading environment, WildFly's class loading is based on modules that have to define explicit dependencies on other modules. Deployments in WildFly are also modules, and do not have access to classes that are defined in jars in the application server unless an explicit dependency on those classes is defined.

可以在 WildFly 9 Documentation

上找到更多信息

基本上,您可以使用您的共享库添加一个模块,并使您的部署依赖于它。

例如,您可以使用 jboss-cli(位于 bin 文件夹中)添加带有 MySQL 连接器 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>

模块名称必须与您在模块添加命令中指定的名称相匹配。

如果您在 Dependencies 部分 MANIFEST.MF 中添加模块名称,则可以省略文件 jboss-deployment-structure.xml