Hello ranchers,
I have had problems with my code in Netbeans 6.5 with Glassfish.
I have the bean
package exemplo.Stateless;
import javax.ejb.Stateless;
/**
*
* @author Higor
*/
@Stateless
public class HelloUserBeanBean implements HelloUserBeanRemote {
public void sayHello(
String name) {
System.out.println("Hello " + name + " welcome to
EJB 3 In Action!");
}
}
I have the Remote....
package exemplo.Stateless;
import javax.ejb.Remote;
/**
*
* @author Higor
*/
@Remote
public interface HelloUserBeanRemote {
public void sayHello(String name);
}
And I have a
test client that use JNDI...
public class HelloUserClient {
//@EJB
public static HelloUserBeanBean helloUser;
public static void main(String[] args) {
//helloUser.sayHello("Curious George");
System.out.println("Invoked EJB successfully .. see server console for output");
try {
InitialContext ctx = new InitialContext();
HelloUserBeanBean bean = (HelloUserBeanBean) ctx.lookup("ejb/HelloUserBeanBeanJNDI");
helloUser.sayHello("Billy Bob");
//System.out.println(result);
System.out.println("testeeeeeeeeeee");
}
catch(Exception ex) {
ex.printStackTrace();
}
}
}
Ok, but when I execute the client I have the follow errors.
Invoked EJB successfully .. see server console for output
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
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at exemplo.Stateless.HelloUserClient.main(HelloUserClient.java:25)
BUILD SUCCESSFULLY (tempo total: 0 segundos)
Seem JNDI problem.
Anyone can Help me please?
Thank youuu,
Higor