On openLiberty, java 8, Using a class
@Singleton(name = "AppContext")
@Startup
public class A implement B{
...
}
@ApplicationScoped
public class C{
@Inject
private A someA;
}
I get a
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type A with qualifiers @Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedMethod] @Inject public someA....
I dont understand why if I dont implement any interface its working but as soon as I add implement B it is not anymore! Didnt find any documentation about that :(
Thx!
It looks like you're declaring a singleton session EJB.
By default, a session bean class which implements no interfaces and doesn't define any views in another way has a no-interface view and so other classes can inject it directly using its class:
However, if a session bean implements an interface then unless you use annotations to explicitly define the bean's business interfaces, all the interfaces it implements are treated as business interfaces and it doesn't get a no-interface view. In this case, it can't be injected directly using its class.
You should either inject the EJB using its interface (i.e.
@Inject private B someB;
) or explicitly declare that the EJB has a no-interface view by adding@LocalBean
toA
. (In this case you may also want to use@Local
to say which other implemented interfaces are business interfaces).