Hi guys,
i'm facing an issue with CODI on Glassfish 4 which i can't observe CDI events
with notifyObserver = Reception.IF_EXISTS if my bean uses a CODI scope, here is
some code:
@ViewAccessScoped
@Named
public class MyBean implements Serializable{
@Inject
Event<MyEvent> myEvent;
public void fire(){
myEvent.fire(new MyEvent());
}
}
@ViewAccessScoped
//@SessionScoped
@Named
public class AnotherBean implements Serializable{
protected Logger log = Logger.getLogger(getClass().getSimpleName());
public void observe(@Observes(notifyObserver = Reception.IF_EXISTS) MyEvent
event){
log.fine("event received:"+event);
}
i receive nullpointer exception when i fire the event:
javax.faces.FacesException: #{myBean.fire}: java.lang.NullPointerException
at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at
org.apache.myfaces.extensions.cdi.jsf.impl.security.SecurityViolationAwareActionListener.processAction(SecurityViolationAwareActionListener.java:56)
at
org.apache.myfaces.extensions.cdi.jsf.impl.config.view.ViewControllerActionListener.processAction(ViewControllerActionListener.java:68)
at
org.apache.myfaces.extensions.cdi.jsf.impl.listener.action.CodiActionListener.processAction(CodiActionListener.java:58)
full stacktrace is here:http://pastebin.com/fMaMqS72
Here is some observations:
- if i replace ViewAccessScoped with SessionScope i get no errors.
- if i remove notifyObserver = Reception.IF_EXISTS i receive the event without
problems
- I have no issue with JbossAS 7, wildfly and also Glassfish 3.1.1.2
I pushed a simple project at github which reproduces the issue:
github.com/rmpestano/codi-issue
any help is appreciated.
Att,
Rafael M. Pestano
Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
Graduando em Ciência da Computação UFRGS
http://conventions.github.io/home/
http://rpestano.wordpress.com/
@realpestano