4 Replies Latest reply on Jan 15, 2006 6:16 PM by cyril.joui

    Lookup of entity bean from remote client not working

    okism

      I have an entity bean:

      package com.test.ejb3;
      
      import java.io.Serializable;
      
      import javax.ejb.Local;
      import javax.ejb.Remote;
      import javax.persistence.Basic;
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.Id;
      import javax.persistence.Table;
      
      @Entity
      @Table(name = "person")
      @Remote(Person.class)
      @Local(Person.class)
      public class Person implements Serializable {
      
       private long id;
      
       private String name;
      
       public Person() {
       };
      
       public void setId(long id) {
       this.id = id;
       }
      
       @Id
       public long getId() {
       return id;
       }
      
       @Basic
       @Column(name = "name")
       public String getName() {
       return name;
       }
      
       public void setName(String name) {
       this.name = name;
       }
      }
      


      The client I wrote is simple:
      package com.test;
      
      import java.util.Enumeration;
      
      import javax.naming.InitialContext;
      import javax.naming.NameClassPair;
      import javax.naming.NamingException;
      
      import com.test.ejb3.Person;
      
      public class TestClient {
      
       /**
       * @param args
       */
       public static void main(String[] args) {
       InitialContext ctx;
       try {
       ctx = new InitialContext();
       Person p = (Person)ctx.lookup(Person.class.getName());
       } catch (NamingException e) {
       e.printStackTrace();
       }
       }
      
      }
      


      It throws:
      javax.naming.NameNotFoundException: com.test.ejb3.Person not bound


      Why doesn't this work?
      I used JMX console and used list method in JNDIView MBean. I compared the result with the result of list method in InitialContext. Initial context showed me only Global JNDI namespace, and I saw in JMX console that there is also Java namespace in which my EntityManager is.