Skip to main content

Writing custom mbeans, and log rotation events

1 reply [Last post]
Joined: 2008-02-20

Hi everybody,

I am trying to write a custom mbean that listens to various events and takes action based on that.


- Generic errors generate an SMS to my cell phone
- When logs are rotated, I want to save the logs out to a different filesystem, and delete the local file.

So my questions are:

1. how do you write an MBean that has access to the classpath of your app? putting it into applications/mbeans won't do that. Ideally I just would like an MBean module in my EAR file, and none of this create-mbean deploy-mbean stuff (and full access to my app's runtime)

2. what is the event for the log being rotated?


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2005-10-28


This is an interesting question and we are trying to address this more completely for V3. In V2, however, the custom MBeans are not part of application, per se. They are part of application server. So, you are right, if your MBean depends on the classes that are part of an application, you have no choice.

But that does not mean you can't write an MBean that's part of your application. That's very much possible. This is because an MBean is just another (set of) class(es) and you can get hold of MBeanServer that comes along with J2SE 5.0 JVM and register your MBean.

Now, since your application has always got an access to application server's public classes, you should be able to use this route.

The LogRotation related event classes are not yet part of public interface of GlassFish, so you've got to use it at your own risk :). Sankar, can you help provide a documentation of those classes?