users@glassfish.java.net

InstanceNotFoundException

From: REV Tamas <tamas.rev_at_gmail.com>
Date: Wed, 4 Nov 2009 16:46:43 +0100

Hi,

I'm writing a jmx NotificationListener (private static class Client
implements NotificationListener)
that would listen to a GlassFish instance and receive notifications about
its logs. I'm trying to set the proper ObjectName.

I learned that

    ObjectName on =new ObjectName("amx:j2eeType=X-BulkAccess,name=na");
    mbsc.addNotificationListener(on, listener, null, null); //mbsc is-a
MBeanServerConnection

would run, but wouldn't catch logging notifications, so I tried

    ObjectName on =new ObjectName("amx:j2eeType=" + XTypes.LOGGING +
",name=na");
    mbsc.addNotificationListener(on, listener, null, null); //mbsc is-a
MBeanServerConnection

But it raises an InstanceNotFoundException, see the details below.
I tried to use "name=na" and setting no name at all, but still, I got the
same exception.

Don't you happen to know an example, how to set the proper ObjectName ?

Regards,
Tamas

--
Exception in thread "main" javax.management.InstanceNotFoundException:
amx:j2eeType=X-Logging,name=na
        at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1094)
        at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getClassLoaderFor(DefaultMBeanServerInterceptor.java:1438)
        at
com.sun.jmx.mbeanserver.JmxMBeanServer.getClassLoaderFor(JmxMBeanServer.java:1276)
        at
com.sun.enterprise.interceptor.DynamicInterceptor.getClassLoaderFor(DynamicInterceptor.java:570)
        at
javax.management.remote.rmi.RMIConnectionImpl$5.run(RMIConnectionImpl.java:1325)
        at java.security.AccessController.doPrivileged(Native Method)
        at
javax.management.remote.rmi.RMIConnectionImpl.getClassLoaderFor(RMIConnectionImpl.java:1322)
        at
javax.management.remote.rmi.RMIConnectionImpl.addNotificationListeners(RMIConnectionImpl.java:946)
        at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source)
        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:619)
        at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
        at
sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
        at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
        at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
        at
javax.management.remote.rmi.RMIConnectionImpl_Stub.addNotificationListeners(Unknown
Source)
        at
javax.management.remote.rmi.RMIConnector.addListenersWithSubjects(RMIConnector.java:570)
        at
javax.management.remote.rmi.RMIConnector.addListenerWithSubject(RMIConnector.java:545)
        at
javax.management.remote.rmi.RMIConnector.access$700(RMIConnector.java:105)
        at
javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.addNotificationListener(RMIConnector.java:1205)
        at jmxclient.Client.main(Client.java:81)
Java Result: 1