users@glassfish.java.net

EJB3 NameNotFoundException with simple local sample

From: angelogeminiani <angelo.geminiani_at_gmail.com>
Date: Thu, 20 Sep 2007 02:40:25 -0700 (PDT)

Hi,
I'm newbie in EJB3 and I've been struggling for 2 days trying to do a simple
JNDI lookup.
I have a stateless session bean (EJB 3.0) in an EJB Module project, and a
Web Project.
The two projects are packaged in a Enterprise Application project.

In my EJB Module I have a POJO that need lookup to ebj object (SimpleBean).
SimpleBean and SimplePOJO are in same EJB Module.

The EJB:

@Local
public interface SimpleLocal{
...
}

@Stateless()
public class SimpleBean
        implements SimpleLocal{
...
}

The POJO:

public class SimplePOJO {
  
  // .ctor
  public SimplePOJO (){
    Context c = new InitialContext();
    SimpleLocal myBean =
(SimpleBean)c.lookup("java:comp/env/ejb/SimpleBean");
  }

}

I tried use my SimpleBean from a servlet using annotation @EJB and here
works fine.
But in my SimplePOJO constructor I get a javax.naming.NameNotFoundException.

Is there something wrong in my code?
Do I need a .xml descriptor?

Thank you,
Angelo

-- 
View this message in context: http://www.nabble.com/EJB3-NameNotFoundException-with-simple-local-sample-tf4486501.html#a12793987
Sent from the java.net - glassfish users mailing list archive at Nabble.com.