WELD-00143伪范围bean具有循环依赖关系

时间:2016-08-08 10:42:17

标签: java junit ejb javabeans cdi

使用WeldJUnit4Runner并收到错误消息:

  

异常0:org.jboss.weld.exceptions.DeploymentException:   WELD-001443:伪范围bean具有循环依赖性。依赖   路径:      - Managed Bean [com.my.own.bounded_contexts.client.cache.cacheClientCommPriorizedAcceptRequestService]   有限定词[@Any @Default],

Weld中针对此问题的任何已知解决方案?

  

更多错误消息:java.lang.ExceptionInInitializerError                   在com.my.own.WeldJUnit4Runner.createTest(WeldJUnit4Runner.java:18)                   在org.junit.runners.BlockJUnit4ClassRunner $ 1.runReflectiveCall(BlockJUnit4ClassRunner.java:244)                   在org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)                   在org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:241)                   在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)                   在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)                   在org.junit.runners.ParentRunner $ 3.run(ParentRunner.java:238)                   在org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:63)                   在org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)                   在org.junit.runners.ParentRunner.access $ 000(ParentRunner.java:53)                   在org.junit.runners.ParentRunner $ 2.evaluate(ParentRunner.java:229)                   在org.junit.runners.ParentRunner.run(ParentRunner.java:309)                   在org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)                   在org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)                   在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)                   在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)                   在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)                   在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)   引起:org.jboss.weld.exceptions.DeploymentException:异常   列表有102个例外:例外0:   org.jboss.weld.exceptions.DeploymentException:WELD-001443:Pseudo   scoped bean具有循环依赖关系。依赖路径:      - Managed Bean [com.my.own.bounded_contexts.client.cache.cacheClientCommPriorizedAcceptRequestService]   有限定词[@Any @Default],      - [BackedAnnotatedField] @Inject private com.my.own.bounded_contexts.client.cache.cacheClientCommPriorizedAcceptRequestService.listener,      - Managed Bean [类com.my.own.bounded_contexts.client.cache.cacheClientCommPriorizedAcceptRequestListener]   有限定词[@Any @Default],      - [BackedAnnotatedField] @Inject private com.my.own.bounded_contexts.client.cache.cacheClientCommPriorizedAcceptRequestListener.clientCommPriorizedAcceptRequestRepository,      - Managed Bean [类com.my.own.bounded_contexts.client.repositories.ClientCommPriorizedAcceptRequestRepository]   有限定词[@Any @Default],      - [BackedAnnotatedField] @Inject @ClientCommPriorizedAcceptRequestCache private   com.my.own.bounded_contexts.client.repositories.ClientCommPriorizedAcceptRequestRepository.clientCallPriorizedAcceptRequestCache,      - 具有限定符的Producer方法[RemoteCache]   [@ClientCommPriorizedAcceptRequestCache @Any]声明为   [[BackedAnnotatedMethod] @Produces   @ClientCommPriorizedAcceptRequestCache public   com.my.own.bounded_contexts.client.cache.cacheClientCommPriorizedAcceptRequestService.getClientCommPriorizedAcceptRequestRemoteCache()],      - Managed Bean [com.my.own.bounded_contexts.client.cache.cacheClientCommPriorizedAcceptRequestService]   限定符[@Any @Default]                   在org.jboss.weld.bootstrap.Validator.reallyValidatePseudoScopedBean(Validator.java:897)

1 个答案:

答案 0 :(得分:3)

Weld在这方面符合规范。

来自CDI spec,第5部分:

  

容器需要支持bean中的圆形   依赖图,其中至少有一个bean参与其中   循环依赖链具有正常范围,如中所定义   正常范围和伪范围。容器不是必需的   支持每个bean参与的循环依赖链   在链中有一个伪范围。

尝试摆脱应用程序中的依赖循环,或者至少为其中一个bean提供正常范围。