将 .jar 部署到 jboss eap 7 时出现反射信息错误
Getting reflective infomation error when deploying a .jar to jboss eap 7
我正在尝试将 ejb jar 文件作为 Maven 项目部署到 jboss eap 7.0.0。该项目使用 Config-1.3.1.jar 作为我已添加到我项目的 pom.xml 的依赖项。我是 jboss 和 maven 的新手,所以我真的不知道我在这里做错了什么。这是 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>xxx.xxx.xxx</groupId>
<artifactId>xxx-xxx-xxx-xxx</artifactId>
<version>xxx</version>
</parent>
<artifactId>xxx-xxx-xxx-ejb</artifactId>
<name>xxx-xxx-xxx-ejb</name>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.javatuples</groupId>
<artifactId>javatuples</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>xxx-xxx-xxx-ejb</finalName>
</build>
但是当我尝试将 jar 部署到 jboss 时,出现错误:
09:50:44,211 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6)
MSC000001: Failed to start service jboss.deployment.unit."xxx-xxx-xxx-ejb.jar".POST_MODULE:
org.jboss.msc.service.StartException in service jboss.deployment.unit."xxx-xxx-xxx-ejb.jar".POST_MODULE: WFLYSRV0153: Failed to
process phase POST_MODULE of deployment "xxx-xxx-xxx-
ejb.jar"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
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 xxx.mbean.ConfigCache with ClassLoader ModuleClassLoader for Module "deployment.xxx-xxx-xxx-ejb.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:106)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:91)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:76)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
... 5 more
Caused by: java.lang.NoClassDefFoundError: com/typesafe/config/Config
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:80)
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)
... 10 more
Caused by: java.lang.ClassNotFoundException: com.typesafe.config.Config from [Module "deployment.xxx-xxx-xxx-ejb.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
... 15 more
有谁知道我在这里做错了什么?如果需要,我很乐意 post 更多信息。
你需要想办法让类在这个依赖中:
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.3.1</version>
<scope>provided</scope>
</dependency>
可能还有这个:
<dependency>
<groupId>org.javatuples</groupId>
<artifactId>javatuples</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
可用于您的 EJB jar。
这通常是通过将这些 jar 与您的 EJB jar 一起打包到一个 EAR 文件中来实现的。
或者,您可以使用 Class Loading in WildFly 10 中描述的方法之一。
最终这取决于您的 EJB 做什么以及它们的客户端(如果有的话)恰好部署在哪里。
例如,将项目的打包类型更改为:
可能更容易
<artifactId>xxx-xxx-xxx-ejb</artifactId>
<packaging>war</packaging>
以便将依赖项添加到 WEB-INF/lib 目录中(如果删除 provided
范围),这比编写 EAR 文件容易得多。
Java EE 6 和 7 允许在 WAR 文件中部署 EJB。
我正在尝试将 ejb jar 文件作为 Maven 项目部署到 jboss eap 7.0.0。该项目使用 Config-1.3.1.jar 作为我已添加到我项目的 pom.xml 的依赖项。我是 jboss 和 maven 的新手,所以我真的不知道我在这里做错了什么。这是 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>xxx.xxx.xxx</groupId>
<artifactId>xxx-xxx-xxx-xxx</artifactId>
<version>xxx</version>
</parent>
<artifactId>xxx-xxx-xxx-ejb</artifactId>
<name>xxx-xxx-xxx-ejb</name>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.javatuples</groupId>
<artifactId>javatuples</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>xxx-xxx-xxx-ejb</finalName>
</build>
但是当我尝试将 jar 部署到 jboss 时,出现错误:
09:50:44,211 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6)
MSC000001: Failed to start service jboss.deployment.unit."xxx-xxx-xxx-ejb.jar".POST_MODULE:
org.jboss.msc.service.StartException in service jboss.deployment.unit."xxx-xxx-xxx-ejb.jar".POST_MODULE: WFLYSRV0153: Failed to
process phase POST_MODULE of deployment "xxx-xxx-xxx-
ejb.jar"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
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 xxx.mbean.ConfigCache with ClassLoader ModuleClassLoader for Module "deployment.xxx-xxx-xxx-ejb.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:106)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:91)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:76)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
... 5 more
Caused by: java.lang.NoClassDefFoundError: com/typesafe/config/Config
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:80)
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)
... 10 more
Caused by: java.lang.ClassNotFoundException: com.typesafe.config.Config from [Module "deployment.xxx-xxx-xxx-ejb.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
... 15 more
有谁知道我在这里做错了什么?如果需要,我很乐意 post 更多信息。
你需要想办法让类在这个依赖中:
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.3.1</version>
<scope>provided</scope>
</dependency>
可能还有这个:
<dependency>
<groupId>org.javatuples</groupId>
<artifactId>javatuples</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
可用于您的 EJB jar。
这通常是通过将这些 jar 与您的 EJB jar 一起打包到一个 EAR 文件中来实现的。
或者,您可以使用 Class Loading in WildFly 10 中描述的方法之一。
最终这取决于您的 EJB 做什么以及它们的客户端(如果有的话)恰好部署在哪里。
例如,将项目的打包类型更改为:
可能更容易<artifactId>xxx-xxx-xxx-ejb</artifactId>
<packaging>war</packaging>
以便将依赖项添加到 WEB-INF/lib 目录中(如果删除 provided
范围),这比编写 EAR 文件容易得多。
Java EE 6 和 7 允许在 WAR 文件中部署 EJB。