Jboss 6 - 启用 CDI 的 bean 部署失败

Jboss 6 - Deployment failed for CDI enabled bean

在站点 CDI Sample 中使用 CDI 创建了一个示例项目,但是在尝试在 Jboss 6 中部署它时,在 error.Is 以下需要包含任何其他 lib 文件解决这个问题?

 Lib jars:
 javaee-api-7.0.jar
 javax.inject-1.jar

Deployment Error: 2015-02-12 12:25:21,852 INFO [org.jboss.ejb3.deployers.JBossASKernel] (WorkerThread#0[192.168.10.119:61928]) and supplies: 2015-02-12 12:25:21,852 INFO [org.jboss.ejb3.deployers.JBossASKernel] (WorkerThread#0[192.168.10.119:61928]) jndi:HelloObserver 2015-02-12 12:25:21,852 INFO [org.jboss.ejb3.deployers.JBossASKernel] (WorkerThread#0[192.168.10.119:61928]) Added bean(jboss.j2ee:ear=J2eeObserver.ear,jar=J2eeObserver-ejb.jar,name=HelloObserver,service=EJB3) to KernelDeployment of: J2eeObserver-ejb.jar 2015-02-12 12:25:22,048 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (WorkerThread#0[192.168.10.119:61928]) Error installing to Create: name=vfs:///E:/jboss-6.1.0.Final/server/default/deploy/J2eeObserver.ear_WeldBootstrapBean state=Configured: java.lang.NullPointerException at org.jboss.weld.util.ApiAbstraction.annotationTypeForName(ApiAbstraction.java:86) [:6.1.0.Final] at org.jboss.weld.ejb.EJBApiAbstraction.<init>(EJBApiAbstraction.java:36) [:6.1.0.Final] at org.jboss.weld.bootstrap.BeanDeployment.<init>(BeanDeployment.java:100) [:6.1.0.Final] at org.jboss.weld.bootstrap.WeldBootstrap$DeploymentVisitor.visit(WeldBootstrap.java:185) [:6.1.0.Final] at org.jboss.weld.bootstrap.WeldBootstrap$DeploymentVisitor.visit(WeldBootstrap.java:197) [:6.1.0.Final] ......

2015-02-12 12:25:22,074 WARN [org.jboss.profileservice.management.upload.remoting.DeployHandler] (WorkerThread#0[192.168.10.119:61928]) Failed to complete command: [start] for deployment: names=[J2eeObserver.ear]: org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

DEPLOYMENTS MISSING DEPENDENCIES: Deployment "jboss-injector:topLevelUnit=J2eeObserver.ear,unit=J2eeObserver-ejb.jar,bean=HelloObserver,interceptor=org.jboss.weld.integration.ejb.SessionBeanInterceptor" is missing the following dependencies: Dependency "<UNKNOWN jboss-injector:topLevelUnit=J2eeObserver.ear,unit=J2eeObserver-ejb.jar,bean=HelloObserver,interceptor=org.jboss.weld.integration.ejb.SessionBeanInterceptor>" (should be in state "Installed", but is actually in state "** UNRESOLVED Demands 'jboss-switchboard:appName=J2eeObserver,module=J2eeObserver-ejb,name=HelloObserver' **")

我想你使用的是JBoss EAP 6 而不是JBoss AS 6(EAP 6 对应的社区版本是JBoss AS 7.1.1)。所以你的编程模型是 Java EE 6 而不是 7。 所以你应该使用 java-ee-6.jar 来编译但不将它包含到你的部署中:服务器提供它。你不需要注入库。

问题已解决,当使用参数启动 Jboss AS 6 时 run -Dcom.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true