4 Replies Latest reply on May 1, 2007 10:03 AM by Chen Chen

    New to EJB3 -- Please help

    Chen Chen Newbie

      Hi all,

      I'm new to EJB. I'm writing a toy EJB, and having problem running the client (bean can be deployed successfully in Eclipse) When running the client, it generates javax.naming.NameNotFoundException: HelloBean not bound.

      Please help. THANKS A LOT!!!

      my config:
      IDE: Eclipse
      JBOSS: 4.0.5

      package examples.session.stateless;
      import javax.ejb.*;
      public interface Hello {
      public String hello() ; //throws java.rmi.RemoteException;

      //BEAN CLASS
      package examples.session.stateless;
      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      import javax.ejb.*;
      public class HelloBean implements Hello {
      public String hello () {
      System.out.println("in hello()...");
      return "Hello, World!";

      <?xml version="1.0" encoding="UTF-8"?>
      <ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
      JBoss Hello World Application

      package examples.session.stateless;
      import java.util.Hashtable;
      import javax.naming.Context;
      import javax.naming.InitialContext;

      public class HelloEJBClient {
      public static void main( String [] args )
      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");

      InitialContext ctx = new InitialContext(env);
      Hello hello = (Hello) ctx.lookup( "HelloBean" );
      catch ( Exception e )
      System.out.println( "Chen - Exception: " + e.getMessage() );