java - WELD-00143 伪作用域 bean 具有循环依赖性

标签 java junit ejb javabeans cdi

使用 WeldJUnit4Runner 并收到错误消息:

Exception 0 : org.jboss.weld.exceptions.DeploymentException: WELD-001443: Pseudo scoped bean has circular dependencies. Dependency path: - Managed Bean [class com.my.own.bounded_contexts.client.cache.cacheClientCommPriorizedAcceptRequestService] with qualifiers [@Any @Default],

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

More error message: java.lang.ExceptionInInitializerError at com.my.own.WeldJUnit4Runner.createTest(WeldJUnit4Runner.java:18) at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:244) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:241) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: org.jboss.weld.exceptions.DeploymentException: Exception List with 102 exceptions: Exception 0 : org.jboss.weld.exceptions.DeploymentException: WELD-001443: Pseudo scoped bean has circular dependencies. Dependency path: - Managed Bean [class com.my.own.bounded_contexts.client.cache.cacheClientCommPriorizedAcceptRequestService] with qualifiers [@Any @Default], - [BackedAnnotatedField] @Inject private com.my.own.bounded_contexts.client.cache.cacheClientCommPriorizedAcceptRequestService.listener, - Managed Bean [class com.my.own.bounded_contexts.client.cache.cacheClientCommPriorizedAcceptRequestListener] with qualifiers [@Any @Default], - [BackedAnnotatedField] @Inject private com.my.own.bounded_contexts.client.cache.cacheClientCommPriorizedAcceptRequestListener.clientCommPriorizedAcceptRequestRepository, - Managed Bean [class com.my.own.bounded_contexts.client.repositories.ClientCommPriorizedAcceptRequestRepository] with qualifiers [@Any @Default], - [BackedAnnotatedField] @Inject @ClientCommPriorizedAcceptRequestCache private com.my.own.bounded_contexts.client.repositories.ClientCommPriorizedAcceptRequestRepository.clientCallPriorizedAcceptRequestCache, - Producer Method [RemoteCache] with qualifiers [@ClientCommPriorizedAcceptRequestCache @Any] declared as [[BackedAnnotatedMethod] @Produces @ClientCommPriorizedAcceptRequestCache public com.my.own.bounded_contexts.client.cache.cacheClientCommPriorizedAcceptRequestService.getClientCommPriorizedAcceptRequestRemoteCache()], - Managed Bean [class com.my.own.bounded_contexts.client.cache.cacheClientCommPriorizedAcceptRequestService] with qualifiers [@Any @Default] at org.jboss.weld.bootstrap.Validator.reallyValidatePseudoScopedBean(Validator.java:897)

最佳答案

Weld 在这方面符合规范。

来自CDI spec , 第 5 节:

The container is required to support circularities in the bean dependency graph where at least one bean participating in every circular chain of dependencies has a normal scope, as defined in Normal scopes and pseudo-scopes. The container is not required to support circular chains of dependencies where every bean participating in the chain has a pseudo-scope.

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

关于java - WELD-00143 伪作用域 bean 具有循环依赖性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38827136/

相关文章:

tomcat - TomEE 未解析 ManagerExecutorService

java - MySQL数据截断: Out of range value for column

java - Java 中跨类共享条件和锁定变量

java - 使用 WebtestClient 测试 MultipartFile

java - Gradle:如何列出所有 "given tests"

java - 为什么我的 JUnit 测试文件是否存在不起作用?

javax.ejb.EJBException : javax. ejb.CreateException:无法创建无状态 EJB junit

java - EJB 强制对资源集合的各个成员进行单线程访问

java - Java 中的不变性

java - EJB 查询语言与 HQL