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.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3917110#3917110

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3917110


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to