I'm struggling a little on CDI Events. I have a class that is implemented as a CDI Singleton almost like this:
import import javax.inject.Singleton;
@Singleton
public class MyClass{
@Inject
Event<StatusUpdateEvent> events;
public MyClass(){};
public void myMethod(){
events.fire(new StatusUpdateEvent());
}
}
Then I have my consumer class implemented as EJB Singleton
import javax.ejb.Singleton;
@Singleton
public class MyObserver(){
public MyObserver(){};
public onStatusUpdateEvent(@Observes StatusUpdateEvent event){
...do something...
}
}
The problem is that when myMethod
is invoked no events is received from myObserver.
MyClass
is included in a library jar of my EAR project (the jar has beans.xml) and MyObserver
is an EJB of the same EAR.
What am I doing wrong? Thanks a lot for your help!