3 Replies Latest reply on Jul 11, 2011 3:51 AM by jaikiran pai

    how to explicitely state a dep. between an @MDB and an @EJB

    Radai Rosenblatt Newbie

      Hi.

       

      i have an MDB with an injected @EJB in it:

       

      public class myMDB ... {

           @EJB ejbRef;

           // code...

      }

       

      the @EJB in question is a @SIngleton @Startup bean, with a @PostConstruct method that in theory should be called before its deployed.

      what actually happens is that jboss 6 creates and invokes this MDB before the EJB it refers to is deployed. my log is full of JNDI lookup errors and (even stranger) calls to the @Singleton BEFORE its init method was invoked. here's an example root JNDI failure:

       

      Caused by: javax.naming.NameNotFoundException: ejbRefBean not bound

              at org.jnp.server.NamingServer.getBinding(NamingServer.java:771) [:5.0.5.Final]

              at org.jnp.server.NamingServer.getBinding(NamingServer.java:779) [:5.0.5.Final]

              at org.jnp.server.NamingServer.getObject(NamingServer.java:785) [:5.0.5.Final]

              at org.jnp.server.NamingServer.lookup(NamingServer.java:396) [:5.0.5.Final]

       

      i've tried making this a little more explicit for jboss, by adding @Depends:

       

      @Depends("jboss.j2ee:ear=my.ear,jar=my.jar,name=ejbRefBean,service=EJB3")

       

      but this doesnt work either. what am i doing wrong? how can i get jboss to not deploy the MDB until the singleton is up and running?