Start of Content Area

Background documentation Getting New Initial Context Using P4 Fails  Locate the document in its SAP Library structure

Problem Description

You are informed that a client fails to get a new initial context using the P4 transport protocol.

Scenario Type:

Error analysis

NetWeaver Component:

J2EE Engine

Validity:

J2EE Engine 6.40 and higher

Decision Roadmap

Prerequisites

-

Main Tools

-

Analysis

The user may receive one of the following exceptions:

     com.sap.engine.services.jndi.persistent.exceptions.NamingException: Exception while trying to get InitialContext [Root exception is com.sap.engine.services.security.exceptions.BaseLoginException: Cannot create new RemoteLoginContext instance.]

     javax.naming.NoInitialContextException: Cannot instantiate class: <WRONG_FACTORY_CLASSNAME> [Root exception is java.lang.ClassNotFoundException: WRONG_FACTORY_CLASSNAME]

     com.sap.engine.services.jndi.persistent.exceptions.NoPermissionException: Exception during getInitialContext operation. Wrong security principles/credentials

The exceptions and what to do about them are now described in detail.

com.sap.engine.services.jndi.persistent.exceptions.NamingException: Exception while trying to get InitialContext [Root exception is com.sap.engine.services.security.exceptions.BaseLoginException: Cannot create new RemoteLoginContext instance.]

In this case the possible reasons may be:

     The J2EE Engine is not started or there are problems with the normal J2EE starting mode. Check if the J2EE Engine is started and if it is not, start the engine and try again to get an initial context. If the engine is up and running, see below.

For example:

This graphic is explained in the accompanying text

 

This graphic is explained in the accompanying text

 

This graphic is explained in the accompanying text

 

This graphic is explained in the accompanying text

     The naming service is not started. Check if the naming service on the J2EE Engine is started. You could do this within the telnet connection:

telnet <server> <telnet port>

Please see also note 531293.

If it is not started (see the picture below), do so with the command

startservice naming

or use the Visual Administrator.

This graphic is explained in the accompanying text

     Incorrect URL and P4 port settings are specified in the environment property Context.PROVIDER_URL. Set the correct URL and P4 port in the environment properties (Context.PROVIDER_URL, <host>:<p4_port>) when you get an initial context.

Example

Example:

    Properties p = new Properties();

    p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");

    p.put(Context.PROVIDER_URL, "<WRONGHOST>:<WRONGPORT>");

    p.put(Context.SECURITY_PRINCIPAL, "<USERNAME>");

    p.put(Context.SECURITY_CREDENTIALS, "<USERPASSWORD>");

javax.naming.NoInitialContextException: Cannot instantiate class: <WRONG_FACTORY_CLASSNAME> [Root exception is java.lang.ClassNotFoundException: WRONG_FACTORY_CLASSNAME]

In this case the problem occurs because an incorrect factory class name is set for the environment property Context.INITIAL_CONTEXT_FACTORY. The correct factory class name is com.sap.engine.services.jndi.InitialContextFactoryImpl

Example

Example:

    Properties p = new Properties();

    p.put(Context.INITIAL_CONTEXT_FACTORY, "WRONG_FACTORY_CLASSNAME");

    p.put(Context.PROVIDER_URL, "<ENGINE_P4_HOST>:<P4_PORT>");

    p.put(Context.SECURITY_PRINCIPAL, "<USERNAME>");

    p.put(Context.SECURITY_CREDENTIALS, "<USERPASSWORD>");

com.sap.engine.services.jndi.persistent.exceptions.NoPermissionException: Exception during getInitialContext operation. Wrong security principles/credentials

In this case the problem occurs because an incorrect user name or/and password are set in the environment properties used to get initial context. Set the correct user name and password which are available for getting the initial context.

Example

Example:

    Properties p = new Properties();

        p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");

    p.put(Context.PROVIDER_URL, "<ENGINE_P4_HOST>:<P4_PORT>");

    p.put(Context.SECURITY_PRINCIPAL, "<WRONG_USERNAME>");

    p.put(Context.SECURITY_CREDENTIALS, "<WRONG_USERPASSWORD>");

Additional Information

-

 

End of Content Area