RMIIO 和 NoClassDefFoundError

RMIIO and NoClassDefFoundError

我正在尝试将文件从客户端 (JSE) 上传到服务器应用程序(Java EE、EJB、Wildfly)。我正在尝试使用 this page 中的第一个示例,但是当我尝试 运行 Wildfly 服务器上的服务器应用程序时 - 我收到此错误:

19:08:30,077 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service jboss.deployment.unit."ProjectEngineerServer.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."ProjectEngineerServer.jar".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "ProjectEngineerServer.jar" at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.2.0.Final.jar:8.2.0.Final] at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final] at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_20] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_20] at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_20] Caused by: java.lang.RuntimeException: JBAS018757: Error getting reflective information for class com.system.main.HandlingBean with ClassLoader ModuleClassLoader for Module "deployment.ProjectEngineerServer.jar:main" from Service Module Loader at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:72) [wildfly-server-8.2.0.Final.jar:8.2.0.Final] at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:58) 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:159) [wildfly-server-8.2.0.Final.jar:8.2.0.Final] ... 5 more Caused by: java.lang.NoClassDefFoundError: com/healthmarketscience/rmiio/RemoteInputStream at java.lang.Class.getDeclaredMethods0(Native Method) [rt.jar:1.8.0_20] at java.lang.Class.privateGetDeclaredMethods(Class.java:2688) [rt.jar:1.8.0_20] at java.lang.Class.getDeclaredMethods(Class.java:1962) [rt.jar:1.8.0_20] at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.(ClassReflectionIndex.java:65) [wildfly-server-8.2.0.Final.jar:8.2.0.Final] at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:68) [wildfly-server-8.2.0.Final.jar:8.2.0.Final] ... 10 more Caused by: java.lang.ClassNotFoundException: com.healthmarketscience.rmiio.RemoteInputStream from [Module "deployment.ProjectEngineerServer.jar: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] ... 15 more 19:08:31,657 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) JBAS014613: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"ProjectEngineerServer.jar\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"ProjectEngineerServer.jar\".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment \"ProjectEngineerServer.jar\" Caused by: java.lang.RuntimeException: JBAS018757: Error getting reflective information for class com.system.main.HandlingBean with ClassLoader ModuleClassLoader for Module \"deployment.ProjectEngineerServer.jar:main\" from Service Module Loader Caused by: java.lang.NoClassDefFoundError: com/healthmarketscience/rmiio/RemoteInputStream Caused by: java.lang.ClassNotFoundException: com.healthmarketscience.rmiio.RemoteInputStream from [Module \"deployment.ProjectEngineerServer.jar:main\" from Service Module Loader]"}}

我不明白为什么找不到 class (com/healthmarketscience/rmiio/RemoteInputStream)。我使用 Maven 并将其添加到我的 pom.xml:

<dependency>
    <groupId>com.healthmarketscience.rmiio</groupId>
    <artifactId>rmiio</artifactId>
    <version>2.0.5</version>
</dependency>

所以我的项目中有 rmiio 库。

我该如何解决这个问题?

我解决了这个问题。一步一步我做了什么:

  1. 我在 Wildfly_HOME 下创建了以下路径:WILDFLY_HOME\modules\system\layers\base\com\healthmarketscience\main 用于 rmiio 库。
  2. 我在main目录下添加了一个rmiio-2.0.5.jar文件和一个module.xml文件。这是 module.xml 文件:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <module xmlns="urn:jboss:module:1.3" name="com.healthmarketscience">
      <resources>
        <resource-root path="rmiio-2.0.5.jar"/>
      </resources>
      <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
      </dependencies>
    </module>
    
  3. 我在项目的 META-INF 目录中添加了一个 jboss-deployment-structure.xml 文件。这是 jboss-deployment-structure.xml 文件:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <jboss-deployment-structure>
        <deployment>
            <dependencies>
                <module name="com.healthmarketscience" slot="main" export="true"/>
            </dependencies>        
        </deployment>
    </jboss-deployment-structure>