javax.naming.NameNotFoundException
pipo Jun 2, 2003 9:48 AMHello,
I try to run a simple example of helloworld EJB!
When I compile my client I have got javax.naming.NameNotFoundException. And apparently the program can't find the org.jnp.server.NamingServer.
I have seen in this forum sometimes we have to define the jndi inside the jboss.xml but I don't use it, is it a bad choice or not? (it's only to display "helloworld").
Thank you for any help and your kind assistance
Here is the code of my very simple client :
========client=========
/*
* TestJBOSS => => HelloWorlClient.java
*
* Created on 2 juin 2003
*/
/**
* @author default
*/
import javax.naming.Context;
import javax.naming.InitialContext;
//import java.util.Hashtable;
import java.util.Properties;
public class HelloWorldClient {
public static void main(String[] args) {
Properties p = new Properties();
p.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
p.setProperty("java.naming.provider.url","localhost:1099");
p.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
p.list(System.out);
/*Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "localhost:1099");
env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");*/
try {
Context ctx = new InitialContext(p);
Object obj = ctx.lookup("HelloWorld");
HelloWorldHome home = (HelloWorldHome) javax.rmi.PortableRemoteObject.narrow( obj, HelloWorldHome.class);
HelloWorld helloWorld = home.create();
System.out.println(helloWorld.hello());
helloWorld.remove();
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception: " + e.getMessage());
}
}
}
========end of client==========
======ejb-jar.xml=============
<?xml version="1.0" ?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
JBoss Hello World Application
<display-name>Hello World EJB</display-name>
<ejb-name>HelloWorld</ejb-name>
TestJBOSS.HelloWorldHome
TestJBOSS.HelloWorld
<ejb-class>TestJBOSS.HelloWorldBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
</enterprise-beans>
</ejb-jar>
=============================