NameNotFoundException JNDI Problem
oli May 6, 2003 8:09 AMHi all,
I have a problem, does many people have, when you have a look with google. But i didn't find a solution.
javax.naming.NameNotFoundException: HelloServer not bound
Why does is the name form the EJB not found
I looked under: http://localhost:8080/jmx-console/index.jsp --> service=JNDIView --> java.lang.String list()
What i have to find? I don't see HelloServer
What's wrong?
I'm working with:
- jboss-3.2.1_tomcat-4.1.24
- eclipse 2.1
- eclipse plugin: EASIE jboss version 1.2 (good thing)
Server Client
- jdk1.4.1_1 - jdk1.4.1_1
- j2sdkee1.4 - log4j.jar
- jbossall-client.jar
JBoss-Protocol
---------------------
15:31:35,016 INFO [URLDeploymentScanner] Started
15:31:35,146 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/conf/jboss-service.xml
15:31:35,156 INFO [Server] JBoss (MX MicroKernel) [3.2.1 (build: CVSTag=JBoss_3_2_1 date=200305041533)] Started in 38s:169ms
15:33:16,844 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/deploy/HelloServer.jar
15:33:16,894 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/deploy/HelloServer.jar
Server-Side
---------------
package test.server;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
public interface HelloServer extends EJBObject { public String sayHello() throws RemoteException; }
package test.server;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface HelloServerHome extends EJBHome {
HelloServer create() throws RemoteException, CreateException; }
package test.server;
import java.rmi.RemoteException;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class HelloServerBean implements SessionBean {
public void ejbCreate(){}
public String sayHello() throws RemoteException{ return "Hello World. This is your sessionbean speaking!";}
public void setSessionContext(SessionContext arg0) throws EJBException, RemoteException { }
public void ejbRemove() throws EJBException, RemoteException {}
public void ejbActivate() throws EJBException, RemoteException {}
public void ejbPassivate() throws EJBException, RemoteException {}}
ejb-jar.xml
--------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE ejb-jar PUBLIC
"-//SUN Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<!-- Session-Beans -->
helloWorld Session Bean example.
<display-name>HelloWorldServerDisplayName</display-name>
<ejb-name>HelloWorldServer</ejb-name> <!--Matches with JBoss.xml -->
test.server.HelloServerHome
test.server.HelloServer
<ejb-class>test.server.HelloServerBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</enterprise-beans>
</ejb-jar>
JBoss.xml
-------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE jboss PUBLIC
"-//JBoss//DTD JBOSS 3.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">
<enterprise-beans>
<ejb-name>HelloWorldServer</ejb-name> <!-- Matches ejb-jar.xml -->
<jndi-name>ejb/HelloServer</jndi-name>
</enterprise-beans>
Client-Side
---------------
package test.client;
import java.rmi.RemoteException;
import java.util.Properties;
import javax.ejb.CreateException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import test.server.HelloServer;
import test.server.HelloServerHome;
public class HelloClient {
public static void main(String[] args) {
Properties props = new Properties();
props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
props.put("java.naming.provider.url", "localhost:1099");
try {
InitialContext ctx = new InitialContext(props);
HelloServerHome theHelloHome = (HelloServerHome) ctx.lookup("ejb/HelloServer");
HelloServer theHelloServer = (HelloServer) theHelloHome.create();
System.out.println(theHelloServer.sayHello());
} catch (CreateException e) {
System.out.println("Can not create a bean: " + e);
e.printStackTrace();
} catch (NamingException e) {
System.out.println("Error using Name Service: " + e);
e.printStackTrace();
} catch (RemoteException e) {
System.out.println("Trouble with remote connection: " + e);
e.printStackTrace();
} catch (Exception e) {
System.out.println("Exception: " + e);
e.printStackTrace();
} } }
Thank's Oli