Reputation: 1165
I've created an Java EE application on Glassfish and it's deployed and run successfully. However when I try to use junit to test the Application Client module, It says javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial I tried with many ways:
Hashtable env=new Hashtable();
env.put("java.naming.factory.initial","com.sun.enterprise.naming.SerialInitContextFactory");
Context c = new InitialContext(env);
Object remote = c.lookup("java:comp/env/BookStore");
and it says cant not find class com.sun.enterprise.naming.SerialInitContextFactory
I'm looking for this issue for 2 days but I've got no hope :( Thanks in advance
Upvotes: 0
Views: 897
Reputation: 32004
Please ensure jar file containing com.sun.enterprise.naming.SerialInitContextFactory
is in your classpath. The jar is provided by Glassfish.
Upvotes: 0
Reputation: 118593
I have to assume that you seen the EJB FAQ for Glassfish. It answers the multitude of questions folks have on how to connect applications to Glassfish.
You also don't mention which version of GF you're using, and that can be important since they use different jars and such.
Upvotes: 1