-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remote CDI events throw Exception instead of triggering the observers #1506
Comments
Can you try on an ApplicationScoped CDI bean rather than an EJB? |
I wouldn't think CDI event bus would work across remote EJBs, as it's inherently local. You should use JMS for tasks like this, which is what it's meant to do |
this is the clustered cdi event bus which works across Hazelcast. |
Right, @smillidge but I still woudn't think it would work with remote EJBs |
It's not a remote EJB just a remote EJB application. However I think it needs to be an ApplicationScoped CDI bean for it to work. |
With an ApplicationScoped bean, I still get the exception:
The one firing the CDI event is no remote EJB, but I do talk to the application using a remote EJB. So remote EJB -> ApplicationScoped -> fires CDI event -> throws exception. To test this I got a local client application that searches for the remote EJB, and calls the method that calls the ApplicationScoped bean. It seems like it cannot talk to Hazelcast. Maybe my configuration is faulty? |
There is a limitation in the remote clustering functionality that it can only be invoked from a CDI bean, not EJB. Since the "invocation context" that you have EJB, you are hitting that limitation. |
@smillidge I have thought about this a bit and this would also be an issue within Hz serializer code. |
Assigned internal issue PAYARA-1566 |
Will this fix include the fact that the observable and the observers are in separate jar(war) files on different levels in the classloader? |
Yes, it should |
Can you post a reproducible test case showing how you are initializing the CDI event bus in each application deployment? |
Download the zip file that contains all the ear files and maven projects I have only included 1 local application and 1 local observer, but for every observer inside every application, the stacktrace get thrown.
|
This is reproducible. Internal issue number is PAYARA-1583. The problem arises in the Remote EJB application as the event is looped back to this application and the ClusteredCDIEventBus in that application. There is a bug whereby if the Clustered CDI Event Bus is initialised in an ejb jar the error occurs. |
Your example application will still have problems with the fix. In particular because the receiver bean is Session Scoped. As the messages are fired remotely there is no concept of "active session" when a remote event is received in the CDI Event Bus. So even with the fix your bean will not receive the event as it is not in the active CDI scope. An Application Scoped Bean will receive the event. |
I think it's normal that an event will not trigger inactive beans. But when I have active Session Scoped beans, (because a clicked on something or opened a page) shouldn't those beans be triggered? At that point they are in an active scope. Or am I wrong? If this is not solvable, how would you make it that Session (or View) Scoped beans can be updated from external events? |
You may potentially have a lot of Session Scoped beans as they are tied to a user's session. Therefore there is no easy way to map the event back to a specific user's session when receiving an event from the event bus. It may be possible to activate the correct session scope by passing some application specific payload into the event and the ApplicationScoped bean. Alternatively you could keep some mapping between SessionID and the data in an Application Scoped Bean and pass the session ID over the event. |
Description
Remote CDI Events don't work (or I'm not implementing it as I should).
Expected Outcome
I expect that when I fire a remote CDI event, all Observers get notified and their method get triggered.
Current Outcome
The following Exception is thrown when Payara tries to trigger the remote Observers. The exception is thrown for every observable.
Steps to reproduce (Only for bug reports)
1 -** Enable Hazelcast**
default-config -> hazelcast -> check the "enabled" box
2 -** Set Hazelcast as the availability service**
default-config -> availability service -> web- and ejb- container -> Persistence type: hazelcast
3 -** Deploy the Remote EJB application**
4 -** Deploy the other application(s)**
5 -** Trigger the Remote CDI event**
Samples
All applications (The remote application and the 'normal' applications) have the following maven dependency:
Remote EJB application:
My listeners are coded like this:
The applications look like this:
Environment
The text was updated successfully, but these errors were encountered: