problem adding notification listener from remote client
mjea Feb 1, 2005 8:25 AMHi all,
I've got a NullPointerException while using the addNotificationListener API in RMIAdaptor with JBoss 3.2.6. I first tried the example code from the admin and development guide and this works well, so I suppose the RMI adaptor is correctly configured. The exception occurs while registering the listener, so I don't even receive a first Notification object.
Here is my code
public class DistantNotificationClient implements RMINotificationListener, Serializable { public DistantNotificationClient() { try{ String url = "jnp://" + "etbs159" + ":1099"; String ini = "org.jnp.interfaces.NamingContextFactory"; String pkgs = "org.jboss.naming,org.jnp.interfaces"; Hashtable env = new Hashtable(); env.put("java.naming.provider.url", url); env.put("java.naming.factory.initial", ini); env.put("java.naming.factory.url.pkgs", pkgs); Context ic = new InitialContext(env); RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/rmi/RMIAdaptor"); ObjectName emitterName = new ObjectName("osp.smf.test:service=BroadcasterTest"); server.addNotificationListener(emitterName, this, null, new Long(System.currentTimeMillis())); }catch(Exception e){ e.printStackTrace(); } } public void handleNotification(Notification event, Object handback){ String type = event.getType(); String message = event.getMessage(); System.out.println("type = "+type+" \t message = "+message); } }
and here is the Exception
java.lang.NullPointerException
at org.jboss.jmx.connector.invoker.InvokerAdaptorService.invoke(InvokerAdaptorService.java:234)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
at sun.reflect.GeneratedMethodAccessor119.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:135)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96)
at org.jboss.jmx.connector.invoker.client.InvokerAdaptorClientInterceptor.invoke(InvokerAdaptorClientInterceptor.java:58)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:55)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
at $Proxy0.addNotificationListener(Unknown Source)
at com.alcatel.osp.mbean.test.DistantNotificationClient.<init>(DistantNotificationClient.java:30)
at com.alcatel.osp.mbean.test.DistantNotificationClient.main(DistantNotificationClient.java:87)
Does anybody have an idea of what went wrong ?
I certainly missed something or did something wrong but I can't find the problem.
Thanks for your help !
Maxime