我的项目结构如此
EmployeeManager(耳)
| --EmployeeManagerEJB(jar)
| --EmployeeManagerJSF(战争)
| --EmployeeManagerIntegration(jar)
EmployeeManager - 包含X_EJB,X_JSF,X_Integration的.ear项目
EmployeeManagerEJB - EJB项目打包到包含JPA实体,EJB无状态Bean实现的jar中
EmployeeManagerJSF - 包含JSF的xhtml页面和控制器的动态Web项目
EmployeeManagerIntegration - 由EJB(在JSF项目中使用),DTO实现的接口
我在EJB Bean实现中使用CDI,例如将一个EJB注入另一个EJB(我通过接口引用,而不是通过实现类引用)。我也在X_JSF的控制器类中通过CDI使用这些无状态Bean。当我尝试部署EAR时,我会收到堆栈跟踪:
16:52:13,694 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."EmployeeManager.ear".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."EmployeeManager.ear".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
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.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.weld.resolution.QualifierInstance.createValues(QualifierInstance.java:128)
at org.jboss.weld.resolution.QualifierInstance.of(QualifierInstance.java:95)
at org.jboss.weld.resolution.ResolvableBuilder.addQualifier(ResolvableBuilder.java:147)
at org.jboss.weld.resolution.ResolvableBuilder.addQualifiers(ResolvableBuilder.java:197)
at org.jboss.weld.resolution.ResolvableBuilder.addQualifiers(ResolvableBuilder.java:192)
at org.jboss.weld.manager.BeanManagerImpl.resolveDecorators(BeanManagerImpl.java:885)
at org.jboss.weld.injection.producer.BeanInjectionTarget.initializeAfterBeanDiscovery(BeanInjectionTarget.java:109)
at org.jboss.weld.injection.producer.InjectionTargetInitializationContext.initialize(InjectionTargetInitializationContext.java:42)
at org.jboss.weld.injection.producer.InjectionTargetService.initialize(InjectionTargetService.java:63)
at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:434)
at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:95)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
... 3 more
这是我从wildfly获得的唯一错误类型的消息,不知道这里可能出错的地方以及从哪里开始搜索。 我怀疑CDI错误是某种原因,但不知道如何调试或其他东西。有什么建议吗?
带注射的示例代码:
1.界面
@Local
public interface ChartService extends Serializable {
Collection<String> getSomething();
}
2。实施
@Stateless
public class ChartServiceImpl implements ChartService {
@Inject DateService dateService;
}
答案 0 :(得分:0)
1.使用限定符来识别可注射的实现
https://docs.oracle.com/javaee/6/tutorial/doc/gjbck.html
或
2.使用@Alternative并声明beans.xml中的一个替代方案