javax.naming.NameNotFoundException: comp not bound
jboss_anto Oct 12, 2005 10:58 AMHi everybody,
I have the following problem when I connect with a client to a Session Bean EJB using JBoss 4.0.3
Starting to resolve HelloWorld Object from Context Object
javax.naming.NameNotFoundException: comp not bound
 at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
 at org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
 at org.jnp.server.NamingServer.getObject(NamingServer.java:528)
 at org.jnp.server.NamingServer.lookup(NamingServer.java:252)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
 at javax.naming.InitialContext.lookup(InitialContext.java:347)
 at client.HelloWorldClient.main(Unknown Source)
I have deployed the ear file into JBOSS_HOME/server/default/deploy and started Jboss with "run.sh" ..
Here the code of the files:
Client code:
public class HelloWorldClient
{
 public static void main( String [] args )
 {
/*
 Hashtable env = new Hashtable();
 env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
 System.out.println(env.toString());
 env.put(Context.PROVIDER_URL,"jnp://192.168.7.19:1099");
*/
 try
 {
 Context iniCtx = new InitialContext();
 System.out.println("Starting to resolve HelloWorld Object from Context Object");
 Context ctx = (Context) iniCtx.lookup("java:comp/env");
 Object obj = ctx.lookup("ejb/HelloWorld" );
 System.out.println("Resolve RMI Object from Naming Context");
 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() );
 }
 }
META-INF deployment files:
application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<display-name>Test application</display-name>
Mail forwarding application
Project.jar
ejb-jar.xml:
<!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>
JBoss Hello World Applicaiton
<display-name>Hello World EJB</display-name>
<enterprise-beans>
<ejb-ref>
<ejb-name>HelloWorld</ejb-name>
server.HelloWorldHome
server.HelloWorld
<ejb-class>server.HelloWorldBean</ejb-class>
<session-type>Stateless</session-type>
</ejb-ref>
</enterprise-beans>
</ejb-jar>
and jboss.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3//EN"
"http://www.jboss.org/j2ee/dtds/jboss-web_3_0.dtd">
<enterprise-beans>
<ejb-name>HelloWorld</ejb-name>
<ejb-ref>
<ejb-ref-name>ejb/HelloWorld</ejb-ref-name>
<jndi-name>ejb/HelloWorld</jndi-name>
</ejb-ref>
</enterprise-beans>
Project.jar :
package server;
/**
* This is the remote interface that the client calls to
* have the EJB do the work.
*/
public interface HelloWorld extends javax.ejb.EJBObject
{
public String hello() throws java.rmi.RemoteException;
}
package server;
import javax.ejb.SessionContext;
/**
* This class is the actual implementation of the business
* logic. This is the EJB for simplicity's sake.
*/
public class HelloWorldBean implements javax.ejb.SessionBean
{
private SessionContext ctx;
public void setSessionContext(SessionContext ctx)
{
this.ctx = ctx;
}
public void ejbRemove()
{
System.out.println( "ejbRemove()" );
}
public void ejbActivate()
{
System.out.println( "ejbActivate()" );
}
public void ejbPassivate()
{
System.out.println( "ejbPassivate()" );
}
/**
* The method called to display the string "Hello World!"
* on the client.
*/
public String hello()
{
System.out.println( "hello()" );
return "Hello World!";
}
}
package server;
/**
* HelloWorldHome provides the container the means to
* create and destroy EJB's.
*/
public interface HelloWorldHome extends javax.ejb.EJBHome
{
HelloWorld create() throws java.rmi.RemoteException,
javax.ejb.CreateException;
}
 
    