1 2 Previous Next 15 Replies Latest reply on Mar 24, 2011 5:14 AM by Steve Button-Oracle

    EJB3 Local interface lookup problem

      I have an ear with ejb's and war's. I am trying to lookup the local interface of my EJB's but couldn't succeed.
      I have tried defining <ejb-local-ref> element on my web.xml but that end me up with the folowing exception on start-up

      "Caused By: javax.naming.NameNotFoundException: While trying to look up ejb-info in ..."

      Any pointers documents would be nice, thanks
        • 1. Re: EJB3 Local interface lookup problem
          René van Wijk
          You can use the following in your web.xml
          The container automatically maps the some/name/Something reference to the package.to.your.Interface business
          interface and binds it to the referring EJB's environment at java:comp/env/some/name/Something.

          You can lookup the EJB by using context.lookup(java:comp/env/some/name/Something).
          • 2. Re: EJB3 Local interface lookup problem
            Use the mapped name for ejb lookup.
            CatalogTestSessionEJBLocal beanLocal = (CatalogTestSessionEJBLocal) context.lookup("EJB3-SessionEJB#model.CatalogTestSessionEJBLocal");
            EJB3-SessionEJB#model.CatalogTestSessionEJBLocal is
            • 3. Re: EJB3 Local interface lookup problem
              Jay SenSharma MiddlewareMagic
              Hi Mcalpay,

              Please refer to the following link which demonstrates the EJB3 Local Lookup scenario: http://middlewaremagic.com/weblogic/?p=39

              Jay SenSharma
              http://middlewaremagic.com/weblogic  (Middleware Magic is Here)
              • 4. Re: EJB3 Local interface lookup problem
                Did you get a good answer?
                I have the same problem where my EJB won't initialize during the server startup. However, now I know how to access a local EJB through ejb-local-ref and all that. But I really want to use the @EJB annotation (where I am seeing this error at startup)
                • 5. Re: EJB3 Local interface lookup problem
                  Jay SenSharma MiddlewareMagic
                  Hi KSunil,

                  Dependency Injection *@EJB* is supported from servlet specification 2.5 only so please make sure that your web.xml uses the following Schema otherwise it will fail....
                  <?xml version="1.0" encoding="UTF-8"?>
                  <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
                  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
                  Jay SenSharma
                  • 6. Re: EJB3 Local interface lookup problem
                    Well, this call to a local EJB2 is coming from another EJB1 which gets called from an external client. So I am not sure why web.xml is involved. In any case, the same code works like a charm in WebSphere (Our software can be deployed on Weblogic or WebSphere). So basically in WebSphere EJB1 can simply use the @EJB annotation to use EJB2.
                    If I can make this happen on Weblogic also, I can rest in peace!
                    As things stand, to make this work on both WebSphere and Weblogic, I have to package the descriptor files and ejb-local-refs and all that good stuff!
                    • 7. Re: EJB3 Local interface lookup problem
                      Jay SenSharma MiddlewareMagic
                      Hi KSunil,

                      you didnot mention in your Post that you want to lookup EJB from another EJB....;)
                      I have the same problem where my EJB won't initialize during the server startup. However, now I know how to access a local EJB through ejb-local-ref and all that. But I really want to use the @EJB annotation (where I am seeing this error at startup)
                      This thread is going on on "web.xml" file....Please have a look at the Thread Originators first comment:
                      I have tried defining <ejb-local-ref> element on my web.xml but that end me up with the folowing exception on start-up
                      • 8. Re: EJB3 Local interface lookup problem
                        I was probably not very clear.
                        I thought the solution, if any, may apply to EJB calling EJB also.
                        Tomorrow, I'll try to see if I can use annotations in servlets directly, buy the original question still remains.
                        • 9. Re: EJB3 Local interface lookup problem
                          Jay SenSharma MiddlewareMagic
                          Hi KSunil,

                          I developed a Simple Article on EJB3 to EJB3 Local lookup which worked for me in WLS10.3.3 Please have a look:

                          Thanks Jay SenSharma
                          http://middlewaremagic.com/weblogic (Middleware Magic Is Here)
                          • 10. Re: EJB3 Local interface lookup problem
                            Thanks for your help. But I just can't get this to work. I am very familiar with J2EE in general. I must be making some silly mistake.
                            I have started from fresh again added 2 EJBs and I get the same issue. I will check with BEA support to see
                            And this is working on WebSphere which picks up the same ejb-jar.xml. So, this tells me that I may need something extra in weblogic-ejb-jar.xml file?
                            • 11. Re: EJB3 Local interface lookup problem
                              For EJBs in the same EAR.

                              For EJBs deployed separately EJB 3.0 does not require the local interface to be available on the global JNDI as EJB 3.1 does. JBoss supports local interface on the global JNDI, but WebLogic doesn't and requires the ejb-local-ref.
                              • 12. Re: EJB3 Local interface lookup problem
                                Hi all,
                                Sorry for this -late- answer, but I just spent two days fighting against weblogic (10.3.1 and 10.3.2) for the very same deployment issue, and I found out the problem came from the name of one of my EJB in the @Stateless annotation:

                                I just removed the 'name' section and replaced
                                @Stateless(name = "ejb/xxxxproject/CommandProcessor", mappedName = "ejb/xxxxproject/CommandProcessor")
                                @Stateless(mappedName = "ejb/xxxxproject/CommandProcessor")

                                It seems there is a sort of an internal resolution issue with a 'complex' or too long EJB name???
                                Anyway I hope this might help...
                                • 13. Re: EJB3 Local interface lookup problem
                                  Thanks for all those folks who tried to help.
                                  And thanks to Oracle support who redirected me to this forum (ha ha). I have figured out the exact issue. Unfortunately, we need our EJB modules in sub directories. For example, we have in application.xml,

                                  <module id="ejb_1"><ejb>webworks/callerEJB.jar</ejb></module>
                                  <module id="ejb_2"><ejb>webworks/localEJB.jar</ejb></module>

                                  and the EJBs won't deploy if you use @EJB annotation. If you take out the extra directory and use

                                  <module id="ejb_1"><ejb>callerEJB.jar</ejb></module>
                                  <module id="ejb_2"><ejb>localEJB.jar</ejb></module>

                                  things work. I think this is a genuine bug. We need to have to have that extra directory. (We have had it like this for the past 7+ years and no reason to change now)
                                  • 14. Re: EJB3 Local interface lookup problem

                                    I'm having the same issue, but I'm not able to resolve it following istructions I found in this thread.
                                    I also tried to follow this thread with no lucky:

                                    Ok, this is my environment:

                                    - Eclipse Helios (on Linux 64bit)

                                    - WebLogic 10.3.3 (and Java6)

                                    - Jersey 1.5 libraries (actually I added all the jersey-archive-1.5.zip jar files into my project - )

                                    My bean interface is:

                                    package reply.camp.webservices;


                                    public interface PaymentItemLocalBusiness{

                                         public String getInfo();


                                    My bean is:

                                    package reply.camp.webservices;

                                    @Stateless(name="PaymentItem", mappedName="PaymentItem")

                                    public class PaymentItem implements PaymentItemLocalBusiness{

                                         public String getInfo(){

                                              return "Info";



                                    My webservice class is:

                                    package reply.camp.webservices;



                                    public class MyBeanWebService {

                                         private PaymentItemLocalBusiness myEJB;

                                         public MyBeanWebService {

                                              final Context context;


                                                   context = new InitialContext();

                                                   myEJB = (PaymentItemLocalBusiness)context.lookup("PaymentItem#reply.camp.webservices.PaymentItemLocalBusiness");

                                              } catch (NamingException e) {


                                                   throw new HTTPException(500);






                                         public String getHello(){

                                              return myEJB.getInfo();



                                    My web.xml

                                    <?xml version="1.0" encoding="UTF-8"?>

                                    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">











                                    <description>JAX-RS Tools Generated - Do not modify</description>

                                    <servlet-name>JAX-RS Servlet</servlet-name>









                                    <servlet-name>JAX-RS Servlet</servlet-name>




                                    I have also a weblogic.xml (it was created by default by Eclipse when I create the Dynamic Web Project), but I didn't modify it.

                                    When I do "Run on Server" from Eclipse, the project is published on Weblogic server. I got no error, so I assume everything is working.

                                    When I call my webservice from whatever webbrowser, I get NameNotFoundException:

                                    javax.naming.NameNotFoundException: While trying to lookup 'PaymentItem#reply.camp.webservices.PaymentItemLocalBusiness' didn't find subcontext 'PaymentItem#reply'. Resolved ''; remaining name 'PaymentItem#reply/camp/webservices/PaymentItemLocalBusiness'

                                         at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)

                                         at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)

                                         at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)

                                         at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)

                                         at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)

                                         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:393)

                                         at javax.naming.InitialContext.lookup(InitialContext.java:392)

                                         at reply.camp.webservices.PaymentItemService.<init>(PaymentItemService.java:33)

                                         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                                         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

                                         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

                                         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

                                         at com.sun.jersey.server.spi.component.ResourceComponentConstructor._construct(ResourceComponentConstructor.java:193)

                                         at com.sun.jersey.server.spi.component.ResourceComponentConstructor.construct(ResourceComponentConstructor.java:182)

                                         at com.sun.jersey.server.impl.resource.PerRequestFactory$PerRequest._getInstance(PerRequestFactory.java:182)

                                         at com.sun.jersey.server.impl.resource.PerRequestFactory$AbstractPerRequest.getInstance(PerRequestFactory.java:144)

                                         at com.sun.jersey.server.impl.application.WebApplicationContext.getResource(WebApplicationContext.java:225)

                                         at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:69)

                                         at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:136)

                                         at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:74)

                                         at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1347)

                                         at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1279)

                                         at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1229)

                                         at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1219)

                                         at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:419)

                                         at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)

                                         at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)

                                         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)

                                         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)

                                         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)

                                         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)

                                         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183)

                                         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3686)

                                         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650)

                                         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

                                         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)

                                         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268)

                                         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)

                                         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)

                                         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)

                                         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

                                    I also tried to follow istructions from the last post of this website:


                                    with no lucky :(

                                    I also added this to web.xml:
                                    but I got an error during deployment:
                                    Caused By: weblogic.deployment.EnvironmentException: [J2EE:160200]Error resolving ejb-ref 'ejb/PaymentItemLocalBusiness' from module 'CampServerSellaRS' of application '_auto_generated_ear_'. The ejb-ref does not have an ejb-link and the JNDI name of the target bean has not been specified. Attempts to automatically link the ejb-ref to its target bean failed because no EJBs in the application were found to implement the 'reply.PaymentItemLocalBusiness' interface. Please link or map this ejb-ref to its target EJB and ensure the interfaces declared in the ejb-ref are correct.
                                         at weblogic.deployment.BaseEnvironmentBuilder.autowireEJBRef(BaseEnvironmentBuilder.java:427)
                                         at weblogic.deployment.EnvironmentBuilder.addEJBReferences(EnvironmentBuilder.java:502)
                                         at weblogic.servlet.internal.CompEnv.activate(CompEnv.java:157)
                                         at weblogic.servlet.internal.WebAppServletContext.activate(WebAppServletContext.java:3117)
                                         at weblogic.servlet.internal.WebAppModule.activateContexts(WebAppModule.java:1497)
                                    1 2 Previous Next