You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Ramakanth Kunapuli <ku...@gmail.com> on 2007/11/14 20:46:07 UTC

How do I expose Catalina MBeans through Java Platform MBeanServer

It appears that tomcat uses different MBeanServer instance from Java's
platform MBeanServer.

Here's a tech tip of making both Tomcat & Java use the same MBean Server
instance.

Drop the attached jar file under <java_home>/jre/lib/ext.
Modify the java execution command to include the following system property.
*
-Djavax.management.builder.initial=SingletonMBeanServerBuilder


*

Re: How do I expose Catalina MBeans through Java Platform MBeanServer

Posted by Ramakanth Kunapuli <ku...@gmail.com>.
It appears the attached jar file was stripped. Here's the java source.

*

import* java.util.concurrent.CountDownLatch;

*

import* javax.management.MBeanServer;
*

import* javax.management.MBeanServerBuilder;
*

import* javax.management.MBeanServerDelegate;

*

public* *class* SingletonMBeanServerBuilder *extends* MBeanServerBuilder {

*private* *static* MBeanServer *theMBeanServer*;

*private* *static* MBeanServerDelegate *theMBeanServerDelegate*;

*private* *static* *final* CountDownLatch *mbeanServerInited* =
*new*CountDownLatch(1);

*private* *static* *final* CountDownLatch *mbeanServerDelegateInited* = *new
* CountDownLatch(1);

*public* SingletonMBeanServerBuilder() {

}

@Override

*public* MBeanServer newMBeanServer(String defaultDomain,

MBeanServer outer, MBeanServerDelegate delegate) {

*return* checkAndInitMBeanServer(defaultDomain, outer, delegate);

}

@Override

*public* MBeanServerDelegate newMBeanServerDelegate() {

*return* checkAndInitMBeanServerDelegate();

}

*private* MBeanServer checkAndInitMBeanServer(String defaultDomain,

MBeanServer outer, MBeanServerDelegate delegate) {

*synchronized* (*mbeanServerInited*) {

*if* (*mbeanServerInited*.getCount() != 0) {

*theMBeanServer* = *super*.newMBeanServer(defaultDomain, outer,

delegate);

*mbeanServerInited*.countDown();

}

}

*return* *theMBeanServer*;

}

*private* MBeanServerDelegate checkAndInitMBeanServerDelegate() {

*synchronized* (*mbeanServerDelegateInited*) {

*if* (*mbeanServerDelegateInited*.getCount() != 0) {

*theMBeanServerDelegate* = *super*.newMBeanServerDelegate();

*mbeanServerDelegateInited*.countDown();

}

}

*return* *theMBeanServerDelegate*;

}

}



On Nov 14, 2007 11:52 AM, Vamsavardhana Reddy <c1...@gmail.com> wrote:

> What does the jar do?  It does not seem to contain source code.
>
> ++Vamsi
>
> On Nov 15, 2007 1:16 AM, Ramakanth Kunapuli <ku...@gmail.com> wrote:
>
> > It appears that tomcat uses different MBeanServer instance from Java's
> > platform MBeanServer.
> >
> > Here's a tech tip of making both Tomcat & Java use the same MBean Server
> > instance.
> >
> > Drop the attached jar file under <java_home>/jre/lib/ext.
> > Modify the java execution command to include the following system
> > property.
> > *
> > -Djavax.management.builder.initial=SingletonMBeanServerBuilder
> >
> >
> > *
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: dev-help@tomcat.apache.org
> >
>

Re: How do I expose Catalina MBeans through Java Platform MBeanServer

Posted by Vamsavardhana Reddy <c1...@gmail.com>.
What does the jar do?  It does not seem to contain source code.

++Vamsi

On Nov 15, 2007 1:16 AM, Ramakanth Kunapuli <ku...@gmail.com> wrote:

> It appears that tomcat uses different MBeanServer instance from Java's
> platform MBeanServer.
>
> Here's a tech tip of making both Tomcat & Java use the same MBean Server
> instance.
>
> Drop the attached jar file under <java_home>/jre/lib/ext.
> Modify the java execution command to include the following system
> property.
> *
> -Djavax.management.builder.initial=SingletonMBeanServerBuilder
>
>
> *
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>