对象不是部署 EAR 应用程序时声明 class 的实例
Object is not an instance of declaring class while deploying EAR application
我的项目有这样的结构
员工经理(耳朵)
|--EmployeeManagerEJB (jar)
|--EmployeeManagerJSF (war)
|--EmployeeManagerIntegration (jar)
EmployeeManager - 包含 X_EJB、X_JSF、X_Integration
的 .ear 项目
EmployeeManagerEJB - 打包到包含 JPA 实体、EJB 无状态 Bean 实现的 jar 中的 EJB 项目
EmployeeManagerJSF - 包含 JSF 的 xhtml 页面和控制器的动态 Web 项目
EmployeeManagerIntegration - 由 EJB 实现的接口(在 JSF 项目中使用)、DTO
我在 EJB Bean 实现中使用 CDI,例如将一个 EJB 注入另一个(我是通过接口引用,而不是通过实现 class)。我还在 X_JSF 的控制器 classes 中通过 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;
}
1., 使用限定符识别可注入实现
https://docs.oracle.com/javaee/6/tutorial/doc/gjbck.html
或
2., 使用@Alternative 并在beans.xml
中声明备选方案之一
我的项目有这样的结构
员工经理(耳朵)
|--EmployeeManagerEJB (jar)
|--EmployeeManagerJSF (war)
|--EmployeeManagerIntegration (jar)
EmployeeManager - 包含 X_EJB、X_JSF、X_Integration
的 .ear 项目
EmployeeManagerEJB - 打包到包含 JPA 实体、EJB 无状态 Bean 实现的 jar 中的 EJB 项目
EmployeeManagerJSF - 包含 JSF 的 xhtml 页面和控制器的动态 Web 项目
EmployeeManagerIntegration - 由 EJB 实现的接口(在 JSF 项目中使用)、DTO
我在 EJB Bean 实现中使用 CDI,例如将一个 EJB 注入另一个(我是通过接口引用,而不是通过实现 class)。我还在 X_JSF 的控制器 classes 中通过 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;
}
1., 使用限定符识别可注入实现
https://docs.oracle.com/javaee/6/tutorial/doc/gjbck.html
或
2., 使用@Alternative 并在beans.xml
中声明备选方案之一