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

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

    hatchetman82

      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?

        • 1. Re: how to explicitely state a dep. between an @MDB and an @EJB
          jaikiran

          Can you try this against our latest AS6 nightly build http://community.jboss.org/thread/161386? I think it should be fixed there. If you still run into issue, then let us know.

          • 2. Re: how to explicitely state a dep. between an @MDB and an @EJB
            hatchetman82

            ok, will do (maybe not right this minute though ...)

            as a side note, just to get that annotation i need to use this in my pom:

             

               <dependency>

                        <groupId>org.jboss.ejb3</groupId>

                        <artifactId>jboss-ejb3-ext-api</artifactId>

                        <scope>provided</scope>

                        <exclusions>

                            <exclusion>

                                <groupId>org.jboss.javaee</groupId>

                                <artifactId>jboss-ejb-api</artifactId>

                            </exclusion>

                            <exclusion>

                                <groupId>org.jboss.metadata</groupId>

                                <artifactId>jboss-metadata</artifactId>

                            </exclusion>

                        </exclusions>

                    </dependency>

             

            because otherwise it'd pull-in the whole ejb-3 (not 3.1) tree and cause compilcation errors. is that the correct maven artifact for @Depends in jboss 6 ?

            • 3. Re: how to explicitely state a dep. between an @MDB and an @EJB
              jaikiran

              Yes, that's the correct one.