Acquiring a Reference to the MBean Server
Procedure
- Acquire a reference to the MBean server:
InitialContext initialCtx = new InitialContext(); MBeanServer mbs = (MBeanServer)initialCtx.lookup("jmx");For more information about how to connect to the MBean Server, see Connecting to an MBeanServer .
- Add a reference from the application to the JMX library.
This is done in the application-j2ee-engine.xml situated in the /META-INF folder of the EAR. In this xml you need to add the following code:
<reference reference-type="weak"> <reference-target target-type="library"> tc~jmx </reference-target> </reference>
Next, see Building ObjectName(s) for the Resource MBean(s)