We use the @ManagedResource and @ManagedOperation all the time. Since most of our singletons are lazy when it publishes the managed JMX bean it creates a cglib proxy to register with the mbean server in order to preserve the laziness. This is good.
The first time this JMX method is invoked, the bean is retrieved from the container and the managed operation method is invoked. If anything fails in between the mbean server calling the proxy and the proxy calling our application code inside the operation -- the exception will go back through RMI and if the client is JConsole or JVisualVm then it will fail as the exception classes aren't on those classpaths. It would be nice if spring would provide a way to enable logging in these scenarios. Or at least log any exceptions encountered during that lazy initialization in between the cglib proxy and calling our application code.
The current workaround is to eagerly init the jmx managed beans to get any failures to happen at startup, which is a fair workaround.
I've added this in a revised fashion, logging such a failure at warn level and with a flattened exception toString instead of a stacktrace - like we do in quite a few other places to clearly raise a warning but avoid flooding the log.