cancel
Showing results for 
Search instead for 
Did you mean: 

Initial Context Factory

Former Member
0 Kudos

Initial Context Factory

Posted: Apr 11, 2005 6:49 AM Reply E-mail this post

Hi

I am trying to develop a EJB Project and trying to call the EAR depployed on the server using JNDI.

I am writing the code using Java Client

Can i have the name of Initial Context Factory for WAS 6.40.

Its Urgent

With Wishes

Krishna kanth

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

com.sap.engine.services.jndi.InitialContextFactoryImpl

Former Member
0 Kudos

Hi Noufal

Thank u very much for ur quick response

it is saying Class not Found Exception

do i need to add any thing to my project

With Wishes

Krishna Kanth

Former Member
0 Kudos

I would need more information regarding your EJB. As you are accessing the EJB remotely, you need the remote interfaces in the client side.

Former Member
0 Kudos

Hi

I am writing the following Code

My EAR is already deployed on the J2ee

This is my client code

Properties prop = new Properties();

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

try{

Context ctx = new InitialContext(prop);

Object obj = ctx.lookup("MyStatelessprojectHome");

MyStatelessprojectHome home = (MyStatelessprojectHome)PortableRemoteObject.narrow(obj,com.satyam.first.MyStatelessprojectHome.class);

MyStatelessproject test = home.create();

System.out.println(test.helloworld());

}catch(Exception e)

{

}

i am getting the following Error

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

at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:652)

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

at javax.naming.InitialContext.init(InitialContext.java:219)

at javax.naming.InitialContext.<init>(InitialContext.java:195)

at satyam.sap.ClientTest.main(ClientTest.java:32)

Caused by: java.lang.ClassNotFoundException: com.sap.engine.services.jndi.InitialContextFactoryImpl

at java.net.URLClassLoader$1.run(URLClassLoader.java:199)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:187)

at java.lang.ClassLoader.loadClass(ClassLoader.java:289)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)

at java.lang.ClassLoader.loadClass(ClassLoader.java:235)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:219)

at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)

at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)

... 4 more

Former Member
0 Kudos

add the following code after the prop.put in your code

prop.put(Context.PROVIDER_URL,"<servername>:<portno>");

Former Member
0 Kudos

port no is generally 50004

Former Member
0 Kudos

Hi

i have tried this

it dosent work

With Wishes

Krishna Kanth

Former Member
0 Kudos

Hashtable ht=new Hashtable();

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

ht.put(Context.PROVIDER_URL,"myserver:50004");

Context ctx=new InitialContext(ht);

TestEjbHome myHome = (TestEjbHome)ctx.lookup("SimpleEjb/testJndi");

TestEjb local=myHome.create();

int d=local.add(10,20);

This is how i did and it works

check if ctx is null or not.

TestEjb is the name of my ejb

Former Member
0 Kudos

Check out this link also

/people/helmut.tammen2/blog/2005/04/06/jndi-lookup-of-ejbs-that-reside-at-web-as

Former Member
0 Kudos

\SAP\JDT\eclipse\plugins\com.sap.tc.ap\comp\SAP-JEE\DCs\sap.com\com.sap.engine.client.lib\_comp\gen\default\public\default\lib\java

here you can find the sapj2eeclient.jar file ad to your build path

Answers (2)

Answers (2)

Former Member
0 Kudos

This might help:

For NW04 and NW04s:

sapj2eeclient.jar

exception.jar

logging.jar

For SAP NetWeaver Application Server, Java EE 5 Edition:

sap.comtcjeclientlibimpl.jar

sap.comtcexception~impl.jar

sap.comtcloggingjavaimpl.jar

You may find these jars from your NetWeaver installation at:

\usr\sap\<sid>\<instanceid>\j2ee\j2eeclient

Former Member
0 Kudos

This might help:

For NW04 and NW04s:

sapj2eeclient.jar

exception.jar

logging.jar

For SAP NetWeaver Application Server, Java EE 5 Edition:

sap.comtcjeclientlibimpl.jar

sap.comtcexception~impl.jar

sap.comtcloggingjavaimpl.jar

You may find these jars from your NetWeaver installation at:

\usr\sap\<sid>\<instanceid>\j2ee\j2eeclient