Skip to Content
avatar image
Former Member

register Mbeans

Hi Experts,

concerning a monitoring of java applications, i am trying to register a simple Mbean. I´ve followed the manual

and tried this code.

InitialContext ctx = new InitialContext();

MBeanServer mbs = (MBeanServer) ctx.lookup("jmx");

ObjectName name = new ObjectName("Ccmx.monitor:name=freespace");

mbs.registerMBean(new Free_space(), name);

or this

InitialContext ctx = new InitialContext();

MBeanServer mbs = (MBeanServer) ctx.lookup("jmx");

Free_space mbean = new Free_space();

ObjectName name =

ObjectNameFactory.getNameForServerChildPerNode(

"My_Free_Space",

"Free_space",

null,

null);

//

mbs.registerMBean(mbean, name);

I´ve already have a public interface and implements my methods, finally i got a MBeanRegistrationException

--> Not a compliant standard MBean.

?? Where is the mistake, or how looks a standard Mbean?

thanks for help....

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Mar 12, 2008 at 05:09 AM

    Hi,

    It could be an AccessPriviledge problem.

    Only an adminstrator can register or unregister Mbeans.

    So for example, if this code is called from a servlet then this servlet should be running under administrator priviledges ie.

    Example:

    Web.xml

    <servlet>

    <servlet-name>InitializationServlet</servlet-name>

    <servlet-class>com.sap.InitializationServlet</servlet-class>

    <run-as>

    <role-name>AdminRoleForRegisteringMBean</role-name>

    </run-as>

    </servlet>

    <security-role>

    <role-name>AdminRoleForRegisteringMBean</role-name>

    </security-role>

    Web-j2ee-engine.xml

    <security-role-map>

    <role-name>AdminRoleForRegisteringMBean</role-name>

    <server-role-name>administrators</server-role-name>

    </security-role-map>

    Hope this helps.

    Best Regards, Gagan.

    Add comment
    10|10000 characters needed characters exceeded