I have an Enterprise Application Archive ( EAR ) containing multiple backend modules ( EJB ) as well as some web modules ( WAR ).
The Event gets fired inside one of the backend modules:
@Inject private Event<MyEvent> myEvent;
...
public void fireEvent() {
myEvent.fire(new MyEvent());
}
...
It can be observed in any of the other backend modules with code like this:
public void listener(@Observes MyEvent myEvent) {
..
}
But I can't retrieve the event inside the WARs. Is this because of classloader visibility (classes from WAR are not visible to EJBs) or should CDI handle this?
If CDI can't be used for application wide events, what are the alternatives?
- JMS
- Guava EventBus
- ...
Is there anything that works with CDI? Maybe some CDI extension that bridges the events into the WARs?
----------- EDIT:
I am able to observe the event if it is fired inside the same WAR. Also I tried to use a @Stateless bean as event listener without success.
Packaging is like this:
- EAR
- WAR ( event should be observed here )
- WAR
- EJB ( event gets fired in here )