users@glassfish.java.net

Re: NotificationListener in AMX

From: <glassfish_at_javadesktop.org>
Date: Tue, 16 Oct 2007 12:16:08 PDT

Without the 8.0 source handy, it's hard to say what's going on.

A few things:

- "ModuleLogLevelsConfig" is not an MBean name (ObjectName).

- It's not correct to conclude that no Notification has been sent. It is only accurate to state that one is not being *received*. It could be being sent in fact, just not being received.

- the class "MyNotificationListener" is not thread safe--make 'objectName' be 'final'. And why does it implement java.rmi.Remote? There is no reason whatsoever to do that.

Which test method is being used? testAMXNotification()?

In testAMXNotification() , you are adding the same NotificationListener "test" to two MBeans. This is not in itself an issue from a JMX perspective, but note that your listener has one variable and can be called for Notifications emitted from the two MBeans, thus printing out only "test", making it impossible to distinguish between them. The variable 'objectName' is not an ObjectName; it's set to "test".

How do you know that System.out.println() is working within the context it's being called from? Put something nasty in there like System.exit() to verify that it's never being called.
[Message sent by forum member 'llc' (llc)]

http://forums.java.net/jive/thread.jspa?messageID=240488