
At this step you create a Servlet, through which you will look up the MBeanServer and register your MBean. It is recommended to do this in the Servlet init() method, because it is invoked once at application startup. In this example this is done in the BankServlet.java Servlet:
InitialContext initCtx = new InitialContext();
MBeanServer mbs = (MBeanServer)initCtx.lookup("jmx");
ObjectName objectMBeanName = ObjectNameFactory.getNameForApplicationResourcePerNode("BankMBean", RuntimeProperties.get(RuntimeProperties.PROPERTY_APPLICATION), ObjectNameFactory.EMPTY_VALUE, ObjectNameFactory.EMPTY_VALUE);
Bank myMBean = new Bank(transaction);
mbs.registerMBean(myMBean, objectMBeanName);