users@glassfish.java.net

Re: How to access a Local EJB3 from a POJO?

From: <glassfish_at_javadesktop.org>
Date: Wed, 24 Oct 2007 08:45:16 PDT

Since you provided very little information on what you're trying to do, I'll just provide a code snippet. At the very least it might prompt you to provide more details on what you're doing, specifically.

[code]
public class ProductProxy
{
  private static ProductsLocal lookupInterface()
  {
    try
    {
      Context c = new InitialContext();
      return (ProductsLocal)c.lookup("java:comp/env/ProductsBean");
    }
    catch(NamingException ne)
    {
      LogProxy.saveEntry(ne);
      throw new RuntimeException(ne);
    }
  }

  public static List<Product> getProducts()
  {
    return lookupInterface().getProducts();
  }
}
[/code]

Take the "/ejb/" out of your lookup string and look for the bean, not the interface. This works for me on local interface lookups.
[Message sent by forum member 'zambizzi' (zambizzi)]

http://forums.java.net/jive/thread.jspa?messageID=241914