gpt4 book ai didi

maven - java.lang.ClassNotFoundException : javax. 企业.event.Event

转载 作者:行者123 更新时间:2023-12-05 07:52:16 25 4
gpt4 key购买 nike

我在将 Java EE 应用程序部署到 WildFly 时遇到问题我尝试了不同的方法。

我通过 maven 原型(prototype)创建了 java 应用程序 (wildfly-javaee7-webapp-ear-archetype)并尝试通过 Idea(和管理控制台)运行到 Wildfy,但部署错误:

Cannot upload deployment: {"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit.\"dtest-ear.ear\".\"dtest-ejb.jar\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"dtest-ear.ear\".\"dtest-ejb.jar\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment \"dtest-ejb.jar\" of deployment \"dtest-ear.ear\" Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class by.mass.service.MemberRegistration with ClassLoader ModuleClassLoader for Module \"deployment.dtest-ear.ear.dtest-ejb.jar:main\" from Service Module Loader Caused by: java.lang.NoClassDefFoundError: Ljavax/enterprise/event/Event; Caused by: java.lang.ClassNotFoundException: javax.enterprise.event.Event from [Module \"deployment.dtest-ear.ear.dtest-ejb.jar:main\" from Service Module Loader]"}}

在日志中:

ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.subunit."dtest-ear.ear"."dtest-ejb.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."dtest-ear.ear"."dtest-ejb.jar".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment "dtest-ejb.jar" of deployment "dtest-ear.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 by.mass.service.MemberRegistration with ClassLoader ModuleClassLoader for Module "deployment.dtest-ear.ear.dtest-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: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: Ljavax/enterprise/event/Event;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2575)
at java.lang.Class.getDeclaredFields(Class.java:1908)
at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57)
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)
... 10 more
Caused by: java.lang.ClassNotFoundException: javax.enterprise.event.Event from [Module "deployment.dtest-ear.ear.dtest-ejb.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

我不知道为什么 cdi-api.jar 不使用 wildfly jar 。

<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>

我删除了 - 提供。 (cdi-api.jar打包到app.ear)并且应用程序在 Wildfly 上运行。但打电话后http://localhost:7001/dtest-web/rest/members我有错误,因为所有@Inject 对象都为空。

ERROR [io.undertow.request] (default task-5) UT005023: Exception handling request to /dtest-web/rest/members: org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76)
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212)
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

enter image description here

这是怎么回事?谁能有一个最小的 REST + EJB 示例?


@Path("/members")
@RequestScoped
public class MemberResourceRESTService {
@Inject
private Logger log;

@Inject
private Validator validator;

@Inject
private MemberRepository repository;

@Inject
MemberRegistration registration;

@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Member> listAllMembers() {
return repository.findAllOrderedByName();
}

@GET
@Path("/{id:[0-9][0-9]*}")
@Produces(MediaType.APPLICATION_JSON)
public Member lookupMemberById(@PathParam("id") long id) {
Member member = repository.findById(id);
if (member == null) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
return member;
}

最佳答案

似乎是部署问题。

我无法直接解决您的问题,但可能最简单的解决方案是将部署模型从 EAR 更改为 WAR 存档。

附言。还请确保您使用的不是不稳定的 WildFly 版本。

关于maven - java.lang.ClassNotFoundException : javax. 企业.event.Event,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33936444/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com