Using Wildfly 8.1 I have several beans which I try to inject several EJB into each other. Lets say I have 3 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 dependency. According to specification:
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
Running above code in container result in an error of the form:
org.jboss.weld.exceptions.DeploymentException: WELD-001443: Pseudo scoped bean has circular dependencies. Dependency path:
-Session bean [class A with qualifiers [@Default @Any]; local interfaces are [A] BackedAnnotatedField] @Inject private B,
[..]
My question here is: what is the scope of @Stateless beans? Is it by default @Dependent? And most of all how can I enable circular dependencies between stateless session beans?
Sorry if the question is too trivial. I will appreciate any good further reading sources which will explain presented behavior. Thanks in advance.
UPDATED Ok. I found the workaround. I've used @EJB annotation instead of @Inject but this does not explain the weird behavior of @Inject. The question remains open but as Mika suggested it may be unresolved issue in both CDI specification and Weld RI.