This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 1264922 - Cannot use CDI in Remote Listeners
Cannot use CDI in Remote Listeners
Product: JBoss Data Grid 6
Classification: JBoss
Component: EAP modules (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Sebastian Łaskawiec
Martin Gencur
Depends On:
  Show dependency treegraph
Reported: 2015-09-21 09:18 EDT by Thomas Qvarnström
Modified: 2015-10-07 08:20 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2015-10-07 08:20:34 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Thomas Qvarnström 2015-09-21 09:18:15 EDT
Description of problem:
Class loading issues for custom java classes when using remote listeners using modules

Version-Release number of selected component (if applicable): 6.5.1

How reproducible:

Steps to Reproduce:
1. Install jboss-datagrid-6.5.1-server, jboss-eap-6.4.0 and 
2. Start the servers 
3. Create a WAR project
4. Create a remote message listener like this:
public class MessageListener {
	private Logger logger = Logger.getLogger(MessageListener.class);
	@Inject @MessageCache
	RemoteCache<String,Message> mc;
	public void handleCreated(ClientCacheEntryCreatedEvent<String> e) {
		String key = e.getKey();"Recieved Cache Entry Created of event type %s", e.getType().toString()));
		Message message = mc.get(key); //LINE 29"Key is %s, value is %s", key,message.getText()));
4. Compile and Deploy everything
5. Add entries to the cache.

Actual results:
14:52:58,396 INFO  [com.redhat.middleware.jdg.chatdemo.test.MessageListener] (Client-Listener-641cb75cefa941e9) Recieved Cache Entry Created of event type CLIENT_CACHE_ENTRY_CREATED
14:52:58,397 ERROR [org.infinispan.client.hotrod.event.ClientListenerNotifier] (Client-Listener-641cb75cefa941e9) ISPN004038: Unexpected error consuming event ClientCacheEntryCreatedEvent(key=6c4aa092-297f-4bb2-8b29-aad68a384b07,dataVersion=1): org.infinispan.commons.CacheListenerException: ISPN004035: Caught exception [java.lang.reflect.InvocationTargetException] while invoking method [public void com.redhat.middleware.jdg.chatdemo.test.MessageListener.handleCreated(org.infinispan.client.hotrod.event.ClientCacheEntryCreatedEvent)] on listener instance: com.redhat.middleware.jdg.chatdemo.test.MessageListener@579d715a
	at org.infinispan.client.hotrod.event.ClientListenerNotifier$ClientListenerInvocation.invoke( [infinispan-client-hotrod-6.3.1.Final-redhat-1.jar:6.3.1.Final-redhat-1]
	at org.infinispan.client.hotrod.event.ClientListenerNotifier$EventDispatcher.invokeCallbacks( [infinispan-client-hotrod-6.3.1.Final-redhat-1.jar:6.3.1.Final-redhat-1]
	at org.infinispan.client.hotrod.event.ClientListenerNotifier$EventDispatcher.invokeClientEvent( [infinispan-client-hotrod-6.3.1.Final-redhat-1.jar:6.3.1.Final-redhat-1]
	at org.infinispan.client.hotrod.event.ClientListenerNotifier$ [infinispan-client-hotrod-6.3.1.Final-redhat-1.jar:6.3.1.Final-redhat-1]
	at java.util.concurrent.Executors$ [rt.jar:1.7.0_71]
	at [rt.jar:1.7.0_71]
	at java.util.concurrent.ThreadPoolExecutor.runWorker( [rt.jar:1.7.0_71]
	at java.util.concurrent.ThreadPoolExecutor$ [rt.jar:1.7.0_71]
	at [rt.jar:1.7.0_71]
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_71]
	at sun.reflect.NativeMethodAccessorImpl.invoke( [rt.jar:1.7.0_71]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke( [rt.jar:1.7.0_71]
	at java.lang.reflect.Method.invoke( [rt.jar:1.7.0_71]
	at org.infinispan.client.hotrod.event.ClientListenerNotifier$ClientListenerInvocation.invoke( [infinispan-client-hotrod-6.3.1.Final-redhat-1.jar:6.3.1.Final-redhat-1]
	... 8 more
Caused by: java.lang.NullPointerException
	at com.redhat.middleware.jdg.chatdemo.test.MessageListener.handleCreated( [classes:]
	... 13 more

Expected results:
A log message showing key and value of event

Additional info:
The exception is thrown because variable mc is null, e.g. CDI injection of the remote cache isn't not successful. One could probably work around the problem by not using CDI etc, but since the MessageListener is deploy as part of the WAR file this doesn't make sense to me.

Note You need to log in before you can comment on or make changes to this bug.