how can I Inject a Bean, that uses a @Named annotation along with a value?
@Named
public class LanguageService{
...
}
public class SomeOtherBean{
@Inject
private LanguageService languageService
}
works without Problem – but how to inject, if i’m using:
@Named("lang")
public class LanguageService{
...
}
@Inject can’t have a value as @ManagedProperty does. (But I wan’t to stay with CDI)
Edit:
I noticed that it doesn’t matter how the bean is named. My Fault that leads to an NPE was simple that i created SomeOtherBean manually, and ofc. no Injection was done. My fault.
CDI selects injectable beans by type (and qualifiers) and not by the annotation parameter. The name is used to address a CDI bean from views, e.g. facelets.