Java EE – why are stateless beans considered pseudo scopes and cannot have circular dependencies?
Using wildfly 8.1, I have several beans, and I try to inject several EJBs into each other It can be said that I have three beans:
@Stateless public class A{ @Inject private B b; } @Stateless public class B{ @Inject private C c; } @Stateless public class C{ @Inject private A a; }
Obviously, I have circular dependence According to specifications:
Running on code in the container causes form errors:
My question is: what is the scope of the @ stateless bean? Is it @ dependent by default? Most importantly, how do I enable circular dependencies between stateless session beans?
I'm sorry if the question is too trivial I would appreciate any good further reading that would explain the behavior presented Thank you in advance
Updated I found a solution I use @ EJB annotations instead of @ inject, but that doesn't explain @ inject's strange behavior This problem is still unsolved, but as Mika said, it may be unsolved in both CDI specification and weld RI
Solution
This is an error in the implementation of wildfly / JBoss CDI Problem description https://issues.jboss.org/browse/CDI-414 The current solution provided in (suggested by @ Mike Braun) is to use @ EJB annotations instead of @ inject