Hi everybody,
I have developed one EJB which contains onne Session bean for business logic and one Entity bean for database access.
Now i want to access this EJB from my Console application.
I have wrriten following code for getting context and creating home object of bean.
jndictxprop.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sap.engine.services.jndi.InitialContextFactoryImpl");
jndictxprop.put(Context.PROVIDER_URL,
"server:50004");
jndictxprop.put(Context.SECURITY_PRINCIPAL, "myLogin");
jndictxprop.put(Context.SECURITY_CREDENTIALS, "myPassword");
try {
Context jndicontext = new InitialContext(jndictxprop);
Object obj =(Object) jndicontext.lookup("StatefullBean");
EMP_StatefullHome home =(EMP_StatefullHome) javax.rmi.PortableRemoteObject.narrow(obj,
EMP_StatefullHome.class);
EMP_Statefull hello = home.create();
System.out.println(hello.GetDetails("720195").getEmp_id());
} catch (Exception e) {
e.printStackTrace();
}
But its giving exception
javax.naming.NoInitialContextException: Cannot instantiate class: com.lti.InitialContextFactoryImpl. Root exception is java.lang.ClassNotFoundException: com.lti.InitialContextFactoryImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:217)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
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 com.lti.bh.UserlistClient.mainClass.main(mainClass.java:37)
If anybody knows then pls help me.
Thank you,
Bhavik