1 Reply Latest reply on May 11, 2007 4:22 PM by alesj

    EJB Injection.

    gumnaam

      I want to use the Spring Deployer to inject EJBs in POJOs.

      I wrote a BeanPostProcessor that will inject EJBs into any POJO having a javax.ejb.EJB annotation.

      But the problem is , the EJBs are not started untill the ear deployes, and the ear is not deployed untill all its components including the -spring.xml file is deployed.
      e.g.

      app.ear
      appcontext-spring.xml
      some-ejbs.jar

      Although the EJBs are deployed before the -spring.xml file is loaded, they are not bound to the JNDI tree, until after the ear has finished deploying. But the ear won't finish deploying untill appcontext-spring.xml is also processed.

      Now if I have a bean post processor that does a JNDI lookup on a perticular EJB, it doesn't find it, as the ejbs are not yet bound.

      Any work around this circular dependency ?
      btw, I am using EJB3 and the JNDI string is ear-filename/EJB3-bean-name/local
      e.g. app/SomeEJBService/local .

      thanks

        • 1. Re: EJB Injection.
          alesj

          My first thoughts on this are that it is probably a misuse.
          My original use case was to enable fine grained beans in EJBs and _not_ vice versa.

          What about if you try with a lazy proxies around actual EJB when referencing them in POJOs?
          So that the actual JNDI hit will be when the EJB bean is first used.

          Or you could change the deployment order - EJBs before Spring beans.