Hi,
Your service is very good.I had a very lo,
April 5, 2007 at 8:33 PM
Hi, Your service is very good.I had a very long time problem.but nobody understand my problem clearly.I want to create a session bean,which is stateless and local.It must be accessed by a main method class within from the same project.I use sun java 8.2 with net beans IDE 5.0.but i got NameNotFoundException even I set environmental properties to the initial context constructor.I have given my client program.please help me to relieve from this problem.
my client program:-
package client; /* * HelloClient.java * * Created on January 27, 2007, 8:37 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ import hello.*; import javax.naming.*; import java.rmi.*; import javax.rmi.*; import javax.ejb.*; import java.util.*; /** * * @author Administrator */ public class HelloClient {
/** Creates a new instance of HelloClient */ public HelloClient() { }
/** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here try { Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory"); p.put(Context.PROVIDER_URL,"file:///localhost:3700/kramesh-java/ejb/Hello-EJB"); //1099 Context context = new InitialContext(p); Context ctx=(Context)context.lookup("java:/comp/env"); Object o=ctx.lookup("ejb/HelloLocalHome"); System.out.println("home object has been brought"); HelloLocalHome home=(HelloLocalHome)o; HelloLocal advice=home.create(); System.out.println(advice.sayHello()); } catch(Exception ex) { ex.printStackTrace(); } }
}
I have created a simple method sayHello() that returns "hello" as String message.
the error i got is as follows
init:
deps-jar:
compile-single:
run-main:
javax.naming.NameNotFoundException; remaining name 'E:\localhost:3700\kramesh-java\ejb\Hello-EJB'
at com.sun.jndi.fscontext.FSContext.checkExists(FSContext.java:850)
at com.sun.jndi.fscontext.FSContext.checkIsDirectory(FSContext.java:883)
at com.sun.jndi.fscontext.FSContext.<init>(FSContext.java:108)
at com.sun.jndi.fscontext.FSContext.<init>(FSContext.java:81)
at com.sun.jndi.fscontext.RefFSContext.<init>(RefFSContext.java:97)
at com.sun.jndi.fscontext.RefFSContextFactory.createContext(RefFSContextFactory.java:42)
at com.sun.jndi.fscontext.RefFSContextFactory.createContextAux(RefFSContextFactory.java:47)
at com.sun.jndi.fscontext.FSContextFactory.getInitialContext(FSContextFactory.java:49)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)