6 Replies Latest reply on Oct 31, 2012 10:33 AM by Piotr Nowicki

    @Singleton / @Startup and <init-on-startup> priorities

    Piotr Nowicki Newbie

      Howdy!

       

      I have a Singleton EJB which is by default starting with AS startup (it's annotated with @Startup):

       

      @Singleton(name="MyInit")

      @Startup

      public class MyInit {

       

          @PostConstruct

          void init() {

              System.out.println("=========== INITIALIZING! ===========");

          }

      }

       

      During my integration tests, I'd like to have the startup disabled, so I define the following ejb-jar.xml:

       

      <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" version="3.1"

          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">

          <enterprise-beans>

              <session>

                  <ejb-name>MyInit</ejb-name>

                 <init-on-startup>false</init-on-startup>

              </session>

          </enterprise-beans>

      </ejb-jar>

       

      However, during deployment, I can still see the '==== INITIALIZING ====' message which indicates that the Singleton is still marked as @Startup.

       

      Am I missing something here? I attach the ready-to-deploy exemplary application.

       

      Cheers!

       

      Edit: forgot to mention that i'm working on JBoss 7.0.1