I'm using OpenDMK v1.0b2 and am trying to add a notification listener to a remote MBean that was mounted via the CascadingService. I'm getting a NotSerializableException from the cascading proxy and can't figure out how to get around that problem. My agent application mounts MBeans from a JVM on a differerent computer using the cascading service. I need to register a listener for notifications from one of the remote MBeans that will update information in various files when it receives notifications from the remote MBean. The handles to these files cannot be serialized so I'm at a loss as to how to proceed. What am I doing wrong? How should I be doing this?
Here's a portion of the stack trace that shows the exception:
Caused by: java.io.NotSerializableException: monitor.MyListener
... 27 more
One other bit of information: the code that is trying to register the notification listener on the remote MBean is running as the result of getting a MBeanServererNotification.REGISTRATION_NOTIFICATION notification when the cascading proxy for the remote MBean is registered in the local MBean server.
I was very silly and used an anonymous inner class for the NotificationFilter, completely forgetting about the implicit pointer to the enclosing, non-serializable class. I made the filter an instance of static inner class and everything is now happy.