Skip to Content
avatar image
Former Member

problem with initialcontext(NoInitialContextException)

hi,

i have written remote client for ejb.

Context ctx = null;

Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialReplicatingContextFactoryImpl");

env.put(Context.PROVIDER_URL, "192.168.1.100:50000");

// env.put("force_remote", true);

env.put(Context.SECURITY_PRINCIPAL, "admin");

env.put(Context.SECURITY_CREDENTIALS, "admin");

try {

ctx = new InitialContext(env);

} catch (NamingException ne) {

System.out.println(ne);

<b>exception is</b>

javax.naming.NoInitialContextException: Cannot instantiate class: com.sap.engine.services.jndi.InitialReplicatingContextFactoryImpl [Root exception is java.lang.ClassNotFoundException: com.sap.engine.services.jndi.InitialReplicatingContextFactoryImpl]

java.lang.NullPointerException

please help me to do this

regards

Guru

<b></b><b></b><b></b><b></b><b></b><b></b><b></b><b></b><b></b>

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    May 06, 2006 at 09:13 AM

    Hi Guru,

    You can refer to the following article for getting InitialContext to the J2EE Engine:

    http://help.sap.com/saphelp_nw04/helpdata/en/b5/3f48e02b2e8e4d9272ee63819bba80/frameset.htm

    I see two problems in your coding:

    You use InitialReplicatingContextFactoryImpl and you are trying to connect to the http port of the Engine, while you should connect to the p4 service port. By default the p4 service port on this system should be 50004.

    The exception that you get is because you are missing sapj2eeclient.jar in the classpath of the client.

    Best Regards

    Vyara

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi

      Did you catch NamingException in a try catch block

      try

      {

      MyExampleLocalHome myExampleLocalHome = (MyExampleLocalHome) ctx.lookup(“localejbs/sap.com/MyEAR/MyExampleBean”);

      }catch (NamingException ne)

      {

      e.printStarckTrace();

      }

      hope this helps , please mark helpful answers

      regards

      rajeshkr

  • avatar image
    Former Member
    May 15, 2006 at 12:07 PM

    hi,

    have you included the client jar .

    you need to obtain the client JAR in order to run the beans from within the client application.

    the procedure for obtaining client jar is:

    http://help.sap.com/saphelp_nw04/helpdata/en/5f/2dd984b5d1304b9155f161568f2f64/frameset.htm

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 06, 2006 at 08:51 AM

    hi guru

    1)If you are accessing the ejb from a standalone client (java program) check whether sapj2eeclient.jar is your classpath ,since the context factory impl class is in this jar.

    2) In your code the please check the p4 port is 50000 . you can check this from visual admin .The default port is 50004.

    hope this helps , please do not forget to reward points if helpful.

    regards

    rajeshkr

    Add comment
    10|10000 characters needed characters exceeded