Skip to Content
author's profile photo Former Member
Former Member

initCtx.lookup("jmx") throws strange Exception


I am trying to get handle of an MBeanServer from the JVM like described

in the Netweaver help (in reality there is still a try .. catch clause to be added):

import javax.naming.InitialContext;



// Lookup MBeanServer from the JNDI

InitialContext initCtx = new InitialContext();

MBeanServer mbs = (MBeanServer) initCtx.lookup("jmx");

But if I do that I alway get this Exception you can see below. So now I wonder do I have a problem with the configuration of my server or is the documentation of SAP wrong? Has somebody else tried something like this.

Thanks for any hints!!


javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

at javax.naming.spi.NamingManager.getInitialContext(

at javax.naming.InitialContext.getDefaultInitCtx(

at javax.naming.InitialContext.getURLOrDefaultInitCtx(

at javax.naming.InitialContext.lookup(

at M.init(

at M.main(

Add comment
10|10000 characters needed characters exceeded

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jul 09, 2004 at 07:43 AM

    Hi Nils,

    did you specify the InitialContext factory to be used? Because that's missing in the code snippet.

    You should use something like

    Properties env = new Properties();

    env.put(Context.INITIAL_CONTEXT_FACTORY, "");


    for more information about creating InitialContext see the documentation at

    Hope that helps.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Ivaylo!

      Thanks for the advice, but the thing is running on the server side and the document you refered me to says the following:

      Clients that are running on the server side do not need to specify any properties. They simply use the InitialContext constructor without parameters:

      Context ctx = new InitialContext();

      And I suppose the "Properties env" is supposed to get in "InitialContext(env);", but since I won't use this call at all ...

      Hm, it is a pity, since sometimes it would really easier not to do it remotely. Any other ideas?

      Thanks in advance,