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.
-
Look what I found:
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=38107
Seems like you have to had this to your jndi.properties:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.provider.url=jnp://localhost:1099 java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Looks like it's all about setting up the connection to the JNDI server.
MMRUser : I'm using glassfish as my server app, In there all the setting are specifically set up all the setting as mentioned here https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB but still no resultRyan Fernandes : Have you done all 5 steps? It should work as advertised on the tin.
0 comments:
Post a Comment