本文介绍了在wildfly-9.0.2.Final中部署第三方jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了向多个应用程序显示外部jar,我通常将外部jar放在JBOSS 5.x的$ JBOSS_HOME / server / default / lib directoy中。这些jar在AS的startp处自动启动。
我将如何在wildfly-9.0.2.Final中执行此操作。

In order to visible external jars to more than one application i usually placed external jars at $JBOSS_HOME/server/default/lib directoy in JBOSS 5.x.These jars were automaically up at startp of AS.How this will i do in wildfly-9.0.2.Final.

@Sam Thankx回复
但是我仍然收到错误,敬请请看我的场景如下
结构

@Sam Thankx for replyBut still i am getting error , Kindly please see my scenario as followingStructure


  1. 在test.ear中有一个名为test.jar的jar档案

  2. 在test.jar中有EJB3会话bean java类。在这个类中有import stmt as。

  1. There is jar archive named as test.jar is present in test.ear
  2. In test.jar there is EJB3 session bean java class. In this class there is import stmt as.

import com.oracle.asmc.ejb3.statelesssession.SLE3DecryptLocal;

import com.oracle.asmc.ejb3.statelesssession.SLE3DecryptLocal;

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

Note - Above testclient.jar is not part of test.ear.(I want to access this testclient.jar from multiple EARs)

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

To deploy test.ear,i have done following steps


  1. ./ jboss-cli.sh -c(出现在bin目录中)

  2. 模块添加 - -name = testclient --resources =〜/ client_jar / testclient.jar

  3. 我在jboss-deployment-structure.xml中添加了以下配置并放在META-INF目录中创建test.ear。

  1. ./jboss-cli.sh -c (present in bin directory)
  2. module add --name=testclient --resources=~/client_jar/testclient.jar
  3. I have added following configuration in jboss-deployment-structure.xml and placed in META-INF directory while creating test.ear.

<?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应用程序,请访问''和travesed link Deployments - > Add - > Add Deployment ---> FINISH
    但仍然有以下错误。

  • For deploying Test.ear applicaiton, accessed 'http://127.0.0.1:9990/' and travesed link Deployments --> Add -->Add Deployment --->FINISHBut still got following error.

    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 for reply

    @Sam thankx for reply

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

    I added 'jboss-deployment-structure.xml' in META-INF of test.jar.

    注意 - 是的,我正在访问'com / oracle / asmc /来自test.jar的ejb3 / statelesssession / SLE3DecryptLocal'(存在于testclient.jar模块中)。

    Note- Yes, I am accessing 'com/oracle/asmc/ejb3/statelesssession/SLE3DecryptLocal' (present in testclient.jar module) from test.jar.

    现在我的test.ear包含

    Now my test.ear contains


    1. META-INF / application.xml

    1. META-INF/application.xml

    test.war

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

    test.jar('jboss-deployment-structure.xml' present in META-INF directory of this test.jar )

    但我仍然遇到以下错误。

    But still i am getting following error.

    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
    


    推荐答案

    使用WildFly完全改变了类加载。您可以阅读更多信息[at]

    Class loading has completely changed with WildFly. You can read more information [at]

    更多信息可在

    基本上,您可以使用共享库添加模块,并使部署取决于它。

    Basically, you can add a module with your shared libraries and make your deployment depends on it.

    例如,您可以使用jboss-cli(位于bin文件夹中)添加带有MySQL Connector Java的模块

    For exemple, you could use the jboss-cli (located in the bin folder) to add a module with 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的文件包含以下信息:

    Then to make your application see it, you can add a file called jboss-deployment-structure.xml containing the following information:

    <?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>
    

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

    The module name must match the name you specified in the module add command.

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

    这篇关于在wildfly-9.0.2.Final中部署第三方jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    09-27 08:41