Search code examples
javadependency-injectionejbearoc4j

Oc4j: Invoking Local EJB from a Web app in the same EAR


I've an EAR app contains two modules.

EJB Module and Web Module.

In web module, I am trying to get a ref to some EJB SLSB, I don't use injection cause the class the I need to invoke the method in is not managed.

I am using the following code from the web module:

IFooBarService service = InitialContext.doLookup("IFooBarService");

IFooBarService: the the Local Interface that defined as ( in the ejb module):

@Local
public interface IFooBarService
{
    // ...
}

Do I miss something? (should I supply environment info?)


Solution

  • From Here: https://forums.oracle.com/forums/thread.jspa?threadID=476903

    The solution is:

    fooBarService = (FooBarService) ((StatelessSessionDefaultLocalHome)
        new InitialContext().lookup("EJBModuleName_FooBarServiceLocal")).create();