views:

32

answers:

1

Hi, I'm having some trubles with NotificationListener on JBoss.

I'm have a MBean on an JBoss, I can connet and call their methods. But when I'm trying to add Notifications y get the next exception:

org.jboss.invocation.JBossLazyUnmarshallingException: getArguments failed
    at org.jboss.invocation.MarshalledInvocation.getArguments(MarshalledInvocation.java:513)
    at org.jboss.jmx.connector.invoker.InvokerAdaptorService.invoke(InvokerAdaptorService.java:230)
    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:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:138)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:90)
    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:140)
    at org.jboss.jmx.connector.invoker.SerializableInterceptor.invoke(SerializableInterceptor.java:74)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:90)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
    at org.jboss.invocation.jrmp.server.JRMPProxyFactory.invoke(JRMPProxyFactory.java:180)
    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:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
    at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:855)
    at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:422)
    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:597)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
    at sun.rmi.transport.Transport$1.run(Transport.java:159)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:637)
Caused by: java.lang.ClassNotFoundException: ar.com.cube3.test.msn.MyListener
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:292)
    at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1119)
    at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:798)
    at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:441)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604)
    at org.jboss.invocation.MarshalledValueInputStream.resolveClass(MarshalledValueInputStream.java:109)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at org.jboss.invocation.MarshalledValue.get(MarshalledValue.java:91)
    at org.jboss.invocation.MarshalledInvocation.getArguments(MarshalledInvocation.java:509)
    ... 40 more

I'm calling the MBean form a client outside JBOSS

the code of the main is:

Properties env = new Properties();
            env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
            env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
            env.put(Context.PROVIDER_URL, "jnp://localhost:1099");

            InitialContext ctx;
            ctx = new InitialContext(env);

            MBeanServerConnection server = (MBeanServerConnection)ctx.lookup("jmx/invoker/RMIAdaptor");


               // get reference to CacheMgmtInterceptor MBean

              String cache_service = "ar.com.cube3.framework.modulos.msn:jndiName=msnControl,service=MSNControlAcceso";
              //String cache_service = "jboss:service=JNDIView";
               ObjectName mgmt_name = new ObjectName(cache_service);
//             
               server.addNotificationListener(mgmt_name,(NotificationListener) new MyListener(), new NotificationFilter() {


                private static final long serialVersionUID = 6404657810887052083L;

                public boolean isNotificationEnabled(Notification notification) {
                    // TODO Auto-generated method stub
                    return true;
                }
            }, null);

            Object obj[]= {"test"};
            Object temp = server.invoke(mgmt_name, "registrarMsnMessenger", obj, new String[]{String.class.getName()});
            System.out.println(temp);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

And the notificationListener Implementation:


import java.io.Serializable;

import javax.management.Notification;
import javax.management.NotificationListener;

public class MyListener  implements   NotificationListener, Serializable{


    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public void handleNotification(Notification notification, Object handback) {
        System.out.println("objecto "+ notification.getMessage());

    }
}

thanks in advance. Andres.

A: 

The problem is that your JBoss server does not have your listener implementation (ar.com.cube3.test.msn.MyListener) in its classpath, so it cannot instantiate it to register it as a listener. Package up all your custom classes (like the listener) into a jar and put the jar into the directory [jboss-home]/server/[server-name]/lib.

Nicholas
Nicholas, yes, you are right, my mistake, I thought that is not necessary put the jar into the lib folder when the class is already in an ear.
aivaldi