Do not use JNDI name lookup to reference the runtime MBean server

WebLogic provides a JNDI name lookup for the runtime MBean server. This rule scans for any string literal with the WebLogic MBean server JNDI name, java:comp/env/jmx/runtime.

For example, this rule flags the JNDI name in this example.

import javax.management.MBeanServer;
import javax.naming.InitialContext;

InitialContext ctx = new InitialContext();
MBeanServer server = (MBeanServer)ctx.lookup("java:comp/env/jmx/runtime");

If your application is using a JNDI name lookup for the MBean server, change the application to use the javax.management.MBeanFactory API to get access to the MBeanServer or to manage custom MBeans. If your code is accessing WebLogic provided MBeans, migrate to similar function provided by WebSphere Application Server.

For applications running in WebSphere Application Server traditional, you can get access to the MBean server using the AdminServiceFactory class.

import javax.management.MBeanServer;
import com.ibm.websphere.management.AdminServiceFactory;

MBeanServer server = AdminServiceFactory.getMBeanFactory().getMBeanServer();

For more information see,