cancel
Showing results for 
Search instead for 
Did you mean: 

register Mbeans

Former Member
0 Kudos

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....

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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.

Former Member
0 Kudos

Thank you, it works

5 globes from me..

best regards