Это мой текущий сценарий:SessionScoped КДИ наблюдатель с @Inject для производителей фасоли
@WebListener
public class WebListenerService implements HttpSessionListener{
.... implement methods
@Produces
@Dependent
public SessionDependentService sessionDependentService(){
}
}
@SessionScoped
@Named
public class AccountController implements Serializable{
//Injected properly and works as expected
@Inject
private SessionDependnetService sessionDependentService;
@Inject
@OnLogin
private Event<Account> accountEvent;
public void onLogin(){
accountEvent.fire(authenticatedAccount);
}
}
@SessionScoped
public class AccountObserver implements Serializable{
//This does not work. It is always null.
@Inject
private SessionDependnetService sessionDependentService;
public void onLoginEvent(@Observes @OnLogin final Account account) {
//When this methods is invoked
//the sessiondependentservice is always null here.
}
}
В AccountController, то SessionDependentService правильно введен и не равно нулю, в то время как в AccountObserver, он всегда равен нулю.
EDIT: Событие, использующее инъекцию параметров, по-прежнему приводит к нулевому значению.
public void onLoginEvent(@Observes @OnLogin final Account account, final SessionDependnetService sessionDependentService) {
//When this methods is invoked
//the sessiondependentservice is always null here.
}
Netbeans правильно подсвечивает это как точку впрыска.
Почему это так?
Я использую wildfly 8 server.