Hi all,
I created a web project and
EJB project in WSAD 5.0. In web project , i created a plain
java class which does a lookup to session bean present in EJB project.
public static void main(
String[] args) {
InitialContext initContext;
Object ref=null;
Properties p = new Properties();
try {
p.put("java.naming.factory.initial","com.sun.jndi.cosnaming.CNCtxFactory");
p.put("java.naming.provider.url","iiop://localhost:2809");
initContext = new javax.naming.InitialContext(p);
ref = initContext.lookup("ejb/FinanceSession"); // Gives error here
} catch (NamingException e) {
e.printStackTrace();
System.out.println("Error is ***"+e.getMessage());
}
FinanceSessionHome finHome =(FinanceSessionHome)PortableRemoteObject.narrow(ref,FinanceSessionHome.class);
FinanceSession fin;
try {
fin = finHome.create();
System.out.println("*****I created bean********");
fin.doWhatever();
} catch (RemoteException e) {
} catch (CreateException e) {
}
When i run the above java class using Run as Java Application, it shows the below error. Can any one help me to solve this.
javax.naming.NameNotFoundException. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:48)
at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve(_NamingContextStub.java:1291)
at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:414)
at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:463)
at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:441)
at javax.naming.InitialContext.lookup(InitialContext.java:359)
at SampleClass.main(SampleClass.java:42)
Error is ***null
java.lang.NullPointerException
at SampleClass.main(SampleClass.java:52)