This is my current scenario:
@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.
}
}
In the AccountController, the SessionDependentService is correctly injected and is not null, while in the AccountObserver, it is always null.
EDIT: Event using the parameter injection still results to a null value.
public void onLoginEvent(@Observes @OnLogin final Account account, final SessionDependnetService sessionDependentService) {
//When this methods is invoked
//the sessiondependentservice is always null here.
}
Netbeans correctly highlights this as an injection point.
Why is this the case?
I am using wildfly 8 server.