0

CDI @Inject を機能させるのに失敗した後、つまり、以下は注入されず、 null を取得しました。

    private Standardizating standardizeService;

@Inject
public void setStandardizating(Standardizating standardizeService) {

    this.standardizeService = standardizeService;
}

注入するクラス:

 @Default
 public class StandardizationService extends Service implements Standardizating {

(私は META-INF\beans.xml を持っています)

CDI 1.0 が私の Eclipse/Kepler for WAS 8.5 のファセットであることに気付きました。ファセットをオンにすると、次の例外が発生しました (少なくとも、ある種の CDI が動作していることがわかります...以前のログには何も表示されませんでした)。

[09/01/15 15:06:14:097 EST] 00000091 StandaloneEJB I StandaloneEJBLifeCycle   startApplication OpenWebBeans Container is starting...
[09/01/15 15:06:14:136 EST] 00000091 Helpers       W   NMSV0606E: Object is not of any type which can be bound.
[09/01/15 15:06:14:140 EST] 00000091 BeansDeployer E BeansDeployer deploy 
                             java.lang.RuntimeException: 
com.ibm.ws.naming.util.CannotBindObjectException: Object is not of any type which can be bound.
    at com.sun.jersey.server.impl.cdi.CDIExtension.initialize(CDIExtension.java:196)
    at com.sun.jersey.server.impl.cdi.CDIExtension.beforeBeanDiscovery(CDIExtension.java:297)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:285)
    at org.apache.webbeans.event.NotificationManager.fireEvent(NotificationManager.java:455)
    at org.apache.webbeans.container.BeanManagerImpl.fireEvent(BeanManagerImpl.java:415)
    at org.apache.webbeans.config.BeansDeployer.fireBeforeBeanDiscoveryEvent(BeansDeployer.java:260)
    at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:159)
    at org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:124)
    at com.ibm.ws.webbeans.common.CommonLifeCycle.startApplication(CommonLifeCycle.java:106)
    at com.ibm.ws.webbeans.services.JCDIComponentImpl.startEJBLifeCycle(JCDIComponentImpl.java:588)
    at com.ibm.ws.webbeans.services.JCDIComponentImpl.stateChanged(JCDIComponentImpl.java:562)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.stateChanged(ApplicationMgrImpl.java:1120)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectEvent(DeployedApplicationImpl.java:1353)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.setState(DeployedApplicationImpl.java:294)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.setState(DeployedApplicationImpl.java:289)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:978)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:774)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplicationDynamically(ApplicationMgrImpl.java:1374)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2179)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:445)
    at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:388)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:116)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$1.run(CompositionUnitMgrImpl.java:663)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5384)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5600)
    at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:677)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:621)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:1266)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:256)
    at javax.management.modelmbean.RequiredModelMBean$4.run(RequiredModelMBean.java:1148)
    at java.security.AccessController.doPrivileged(AccessController.java:252)
    at com.ibm.oti.security.CheckedAccessControlContext.securityCheck(CheckedAccessControlContext.java:30)
    at sun.misc.JavaSecurityAccessWrapper.doIntersectionPrivilege(JavaSecurityAccessWrapper.java:41)
    at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1142)
    at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:995)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:848)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:774)
    at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1335)
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
    at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1228)
    at com.ibm.ws.management.application.sync.StartDeploymentTask.startDeployment(StartDeploymentTask.java:247)
    at com.ibm.ws.management.application.sync.StartDeploymentTask.fullAppUpdate(StartDeploymentTask.java:119)
    at com.ibm.ws.management.application.sync.StartDeploymentTask.performTask(StartDeploymentTask.java:107)
    at com.ibm.ws.management.application.sync.AppBinaryProcessor$ExpandApp.expand(AppBinaryProcessor.java:1711)
    at com.ibm.ws.management.application.sync.AppBinaryProcessor.postProcessSynchronousExt(AppBinaryProcessor.java:751)
    at com.ibm.ws.management.bla.sync.BLABinaryProcessor.postProcess(BLABinaryProcessor.java:599)
    at com.ibm.ws.management.bla.sync.BLABinaryProcessor.onChangeCompletion(BLABinaryProcessor.java:476)
    at com.ibm.ws.management.bla.sync.BinaryProcessorWrapper.onChangeCompletion(BinaryProcessorWrapper.java:109)
    at com.ibm.ws.management.repository.FileRepository.postNotify(FileRepository.java:1924)
    at com.ibm.ws.management.repository.FileRepository.update(FileRepository.java:1433)
    at com.ibm.ws.management.repository.client.LocalConfigRepositoryClient.update(LocalConfigRepositoryClient.java:189)
    at com.ibm.ws.sm.workspace.impl.WorkSpaceMasterRepositoryAdapter.update(WorkSpaceMasterRepositoryAdapter.java:665)
    at com.ibm.ws.sm.workspace.impl.RepositoryContextImpl.update(RepositoryContextImpl.java:1998)
    at com.ibm.ws.sm.workspace.impl.RepositoryContextImpl.synch(RepositoryContextImpl.java:1946)
    at com.ibm.ws.sm.workspace.impl.WorkSpaceImpl.synch(WorkSpaceImpl.java:549)
    at com.ibm.ws.management.configservice.ConfigServiceImpl.save(ConfigServiceImpl.java:719)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:256)
    at javax.management.modelmbean.RequiredModelMBean$4.run(RequiredModelMBean.java:1148)
    at java.security.AccessController.doPrivileged(AccessController.java:252)
    at com.ibm.oti.security.CheckedAccessControlContext.securityCheck(CheckedAccessControlContext.java:30)
    at sun.misc.JavaSecurityAccessWrapper.doIntersectionPrivilege(JavaSecurityAccessWrapper.java:41)
    at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1142)
    at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:995)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:848)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:774)
    at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1335)
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
    at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1228)
    at com.ibm.ws.management.remote.AdminServiceForwarder.invoke(AdminServiceForwarder.java:346)
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1465)
    at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:85)
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1306)
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1398)
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
    at javax.management.remote.rmi._RMIConnectionImpl_Tie.invoke(_RMIConnectionImpl_Tie.java:751)
    at javax.management.remote.rmi._RMIConnectionImpl_Tie._invoke(_RMIConnectionImpl_Tie.java:158)
    at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:669)
    at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:523)
    at com.ibm.rmi.iiop.ORB.process(ORB.java:523)
    at com.ibm.CORBA.iiop.ORB.process(ORB.java:1575)
    at com.ibm.rmi.iiop.Connection.doRequestWork(Connection.java:3039)
    at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2922)
    at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:64)
    at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)
Caused by: com.ibm.ws.naming.util.CannotBindObjectException: Object is not of any type which can be bound.
    at com.ibm.ws.naming.util.Helpers.processJavaObjectForBinding(Helpers.java:718)
    at com.ibm.ws.naming.jndicos.CNContextImpl.doRebind(CNContextImpl.java:2076)
    at com.ibm.ws.naming.jndicos.CNContextImpl.rebind(CNContextImpl.java:697)
    at com.ibm.ws.naming.jndicos.CNContextImpl.rebind(CNContextImpl.java:717)
    at com.sun.jersey.server.impl.cdi.CDIExtension.initialize(CDIExtension.java:193)
    ... 108 more

このJarでもJersey JAX-RSに使用されるJerseyライブラリがいくつかありますが、この例外はIBMライブラリを参照しているようです。NMSV0606E は、オブジェクトが CORBA オブジェクト、EJB、シリアライズされたオブジェクトなどではないという問題を強調しているようです。単純なオブジェクトを注入しようとしていますが、これは CDI で実行できるはずです。ファセット CDI 1.0 は、シンプルなオブジェクト インジェクションをサポートしていますか? 私はこれを特定できませんでした。

どんな助けでも感謝しますありがとう

4

1 に答える 1

0

アプリには次の 2 つの問題がある可能性があります。

  • デフォルトの WebSphere JAX-RS プロバイダーの代わりに Jersey を使用する場合は、それを分離共有ライブラリーとして正しく構成する必要があります - これを確認してください - Websphere 8 での JAX-RS Jersey 2.10 サポート
  • JAX-RS コンテナを置き換えると、残念ながらこれらのクラスでは CDI が機能しなくなります。ここを参照してください。

JAX-RS ランタイム環境を無効にすると、基本 JAX-RS ランタイム機能、Enterprise JavaBeans (EJB) ランタイム統合、Java Contexts and Dependency Injection (JCDI) ランタイム統合、Servlet 3.0 Web コンテナー統合などの JAX-RS 機能が使用できなくなります。 .

したがって、本当にジャージーを使用する必要がない限り、デフォルトの WebSphere JAX-RS 実装に切り替えることをお勧めします。そうすれば、CDI が機能します。

于 2015-01-10T12:13:04.463 に答える