Here's my Bean class source
@Stateless(mappedName="StringVal") public class NewSessionBean implements NewSessionRemote {
String val = null;
public String stringChange(int parameter) {
while(parameter < 5){
switch (parameter){
case 1: System.out.println(val + "One" + ",");
case 2: System.out.println(val + "Two" + ",");
case 3: System.out.println(val + "Three" + ",");
case 4: System.out.println(val + "Four" + ",");
}
}
return val;
}
}
And here's my client class for this bean (Stand Alone Client)
import endpoint.NewSessionRemote; import javax.naming.InitialContext;
public class TestLogicBean {
static String retVal = null;
public static void main(String[] args) {
try {
InitialContext ctx = new InitialContext();
NewSessionRemote br = (NewSessionRemote) ctx.lookup("StringVal");
for (int i = 0; i < 5; i++) {
String retVal1 = br.stringChange(i);
System.out.println("EJB message is:" + retVal1);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
But i'm getting this Exception "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 have tried several ways to make this,but still it gives this exception.