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

initCtx.lookup("jmx") throws strange Exception

Hi!

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;

import javax.management.MBeanServer;

...

// 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!!

Nils

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(NamingManager.java:640)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)

at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)

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

at M.init(M.java:33)

at M.main(M.java:114)

Add a comment
10|10000 characters needed characters exceeded

Related questions

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, "com.sap.engine.services.jndi.InitialContextFactoryImpl");

    ..........

    for more information about creating InitialContext see the documentation at http://help.sap.com/saphelp_nw04/helpdata/en/08/8f633e0084e946e10000000a114084/frameset.htm

    Hope that helps.

    Add a 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,

      Nils

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.