11 Replies Latest reply: Feb 15, 2011 7:44 PM by ksunil RSS

    @EJB annotation to look at a local EJB3.0 does not work

    ksunil
      When I have something like

      @EJB CalculatorLocal calcLocalAnnotated;

      from another EJB, the server does not even come up. I see an error like


      Unable to deploy EJB: foo from myFoo.jar:

      While trying to look up ejb-info in .....
      at weblogic.ejb.container.deployer.EJBModule.activate(EJBModule.java:514)

      Why does this not work in 10.3.3? I can get this to work if I remove the @EJB annotation and put in ejb local refs in ejb-jar.xml and all that and do a JNDI lookup on the local interface etc etc. But I would like to see the @EJB work in 10.3.3

      Can some one confirm if this is how it is going to be?

      Thanks
        • 1. Re: @EJB annotation to look at a local EJB3.0 does not work
          648844
          Can you please print the error message you are seeing in its entirety?

          Also, is the EJB with the @EJB declaration and the target EJB packaged in the same application? In WLS, they need to be in the same application for the auto-wiring of @EJB to work.

          Finally, as a work-around, you should be able to specify the JNDI name of the target EJB using the mappedName attribute of the @EJB annotation.

          - Matt
          • 2. Re: @EJB annotation to look at a local EJB3.0 does not work
            ksunil
            I am using a local EJB from another (remote) EJB. And trying to use @EJB. I have figured out the workaround (using local-ejb-ref and jndi names etc). But wanted to see what the issue is. Yes they are in the same .ear file. And the server does come up. The EJB is not deployed.


            Here is what I see when the server comes up.

            INFO: Completed initializing Sun's JavaServer Faces implementation (1.2_03-b04-F
            CS) for context '/console'
            <Feb 11, 2011 9:13:13 PM GMT> <Error> <Deployer> <BEA-149231> <Unable to set the
            activation state to true for the application 'WebWORKSApp'.
            weblogic.application.ModuleException: Exception activating module: EJBModule(webworks/EventService.jar)


            Unable to deploy EJB: webworks.event.ejb.EventService from webworks/EventService.jar:

            While trying to look up ejb-info in /app/ejb/webworks.


            at weblogic.ejb.container.deployer.EJBModule.activate(EJBModule.java:514)
            at weblogic.application.internal.flow.ModuleListenerInvoker.activate(ModuleListenerInvoker.java:227)
            at weblogic.application.internal.flow.DeploymentCallbackFlow$2.next(DeploymentCallbackFlow.java:532)
            at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
            at weblogic.application.internal.flow.DeploymentCallbackFlow.activate(DeploymentCallbackFlow.java:165)
            Truncated. see log file for complete stacktrace

            Caused By: javax.naming.NameNotFoundException: While trying to look up ejb-info
            in /app/ejb/webworks.; remaining name 'ejb-info'
            at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
            at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNamingNode.java:144)
            at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)
            at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:393)
            at weblogic.deployment.BaseEnvironmentBuilder.autowireEJBRef(BaseEnvironmentBuilder.java:408)
            Truncated. see log file for complete stacktrace
            >
            <Feb 11, 2011 9:13:13 PM GMT> <Notice> <Log Management> <BEA-170027> <The Server
            has established connection with the Domain level Diagnostic Service successfully.>
            <Feb 11, 2011 9:13:13 PM GMT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN>
            • 3. Re: @EJB annotation to look at a local EJB3.0 does not work
              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:
              http://middlewaremagic.com/weblogic/?p=5532


              .
              .
              Thanks Jay SenSharma
              http://middlewaremagic.com/weblogic (Middleware Magic Is Here)
              • 4. Re: @EJB annotation to look at a local EJB3.0 does not work
                ksunil
                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
                • 5. Re: @EJB annotation to look at a local EJB3.0 does not work
                  dvohra21
                  For EJBs in the same EAR.
                  http://www.java2s.com/Code/Java/EJB3/UseContextToLookupAnotherEjb.htm

                  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.
                  • 6. Re: @EJB annotation to look at a local EJB3.0 does not work
                    ksunil
                    I know how to make this work by doing lookups. I am trying to see if I can merely do

                    @EJB CalculatorLocal2 calc2;

                    int x= calc2.sum(add1,add2);


                    And this is where I am having issues with BEA. As long as there is this @EJB annotation, the server won't deploy this EJB! And the above coed works on WebSphere. Are you saying that the correct way to this is the following 3 lines?

                    @EJB(name = "calc", beanInterface = CalculatorLocal2 .class)
                    Context ctx = new InitialContext();
                    CalculatorLocal2 a = (CalculatorLocal2 ) ctx.lookup("java:comp/env/calc");

                    and that I shouldn't bother about ejb-local-refs and all that?
                    • 7. Re: @EJB annotation to look at a local EJB3.0 does not work
                      dvohra21
                      Is the error still generated with:
                      @EJB(name = "calc", beanInterface = CalculatorLocal2 .class)
                      Context ctx = new InitialContext();
                      CalculatorLocal2 a = (CalculatorLocal2 ) ctx.lookup("java:comp/env/calc");

                      Edited by: dvohra16 on Feb 14, 2011 12:14 PM
                      • 8. Re: @EJB annotation to look at a local EJB3.0 does not work
                        ksunil
                        so far, I am afraid so.
                        Only way I have been able to get this to work is by having a full ejb-local-ref (ejb/LocalCalc2) in the descriptor and then use ic.lookup(java:comp/env/ejb/LocalCalc2) in the code. Not very sure why @EJB forms are not working.
                        I'll work on stripping down the server to the bare minimum.
                        • 9. Re: @EJB annotation to look at a local EJB3.0 does not work
                          dvohra21
                          Refer
                          http://debupanda.blogspot.com/2007/03/using-ejb-annotation-across-different.html
                          • 10. Re: @EJB annotation to look at a local EJB3.0 does not work
                            765057
                            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")
                            by
                            @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...
                            • 11. Re: @EJB annotation to look at a local EJB3.0 does not work
                              ksunil
                              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)