Skip to Main Content

Application Development Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

javax.naming.NameNotFoundException: While trying to look up comp/jmx/runtime

906980Jul 5 2013

I have a J2EE application with the following format.

     abc.ear

       |

       |---- xyz.war

       |        |

       |       |-- WEB-INF

       |       |-- jamagent.java (Servlet)

       |

       |

       |---- APP-INF

       |        |

       |        |---- MDA.jar

       |                  |

       |                  |--- MDAMBeanRegister.java

       |

       |

       |----WEB-INF

Here, I have piece of code in MDA.jar(MDAMBeanRegister) which basically registering mbean to mbean server like the following and works fine.

Now, the requirement is to register this mbean from the jamagent.java(Servlet) when it gets initialized. When i put the same piece code in the jamagen.java, I get the following exception which says jndi lookup fails.

When i change the jndi to "java:comp/env/jmx/runtime", look up goes fine. Why is it that jamagent.java did not able to access it? Why should I be using "java:comp/env/jmx/runtime" instead of "java:comp/jmx/runtime" in the Servlet context?

I came across this documentation for this. But my question is there a way to access it?

http://docs.oracle.com/cd/E13222_01/wls/docs90/jmx/accessWLS.html#1119237

MDADataCollectorRuntimeMBean mbean = null;

try {

            String serverRuntime = "mda:ServerRuntime=TestServer,Name=mdaMBean,Location=TestServer,Type=MDADataCollectorRuntimeMBean";

            InitialContext ctx = new InitialContext();

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

           

            RuntimeServiceMBean rsMBean = (RuntimeServiceMBean) MBeanServerInvocationHandler.newProxyInstance(server,

                                                        new ObjectName(RuntimeServiceMBean.OBJECT_NAME));

            ServerRuntimeMBean serverRuntime = rsMBean.getServerRuntime();

            String objectName = getObjectName(serverRuntime);

            service = new ObjectName(objectName);

            mbean = new MDADataCollectorRuntimeMBeanImpl();

            server.registerMBean(mbean, service);

           

  } catch (InstanceAlreadyExistsException iae) {

            logger.severe(DEBUG_CODE+"Instance already exists..Re-registering");

            try {

                server.unregisterMBean(service);

                server.registerMBean(mbean, service);

            } catch(Exception ex) {

                logger.throwing(this.getClass().getName(), "postStart", ex);

            }

        } catch(Exception ex) {

                logger.throwing(this.getClass().getName(), "postStart", ex);

        }

Excepiton Trace:

javax.naming.NameNotFoundException: While trying to look up comp/jmx/runtime in /app/webapp/jamagent/386493078.; remaining name 'comp/jmx/runtime'

        at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)

        at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNamingNode.java:144)

        at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)

        at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:411)

        at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:45)

        at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:130)

        at javax.naming.InitialContext.lookup(InitialContext.java:392)

        at jamagent.jaminit.enableMDA(jaminit.java:84)

        at jamagent.jaminit.init(jaminit.java:272)

        at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)

        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)

        at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)

        at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)

        at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)

        at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)

        at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985)

        at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959)

        at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878)

        at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3153)

        at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)

        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)

        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)

        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)

        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)

        at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)

        at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)

        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)

        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)

  at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)

        at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)

        at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:636)

        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)

        at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205)

        at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:58)

        at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)

        at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)

        at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)

        at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)

        at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)

        at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)

        at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)

        at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)

        at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)

        at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)

        at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)

        at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)

        at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)

        at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)

        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)

        at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 2 2013
Added on Jul 5 2013
0 comments
3,670 views