6 Replies Latest reply on Jan 26, 2011 11:49 PM by Ales Justin

    initialize-in-order in application.xml honored?

    henk de boer Master

      It looks like the new initialize-in-order element in application.xml does not seem to be honored by JBoss AS 6.

       

      I created a simple test ear module with a single web and ejb module. The EJB module only contains an (empty) bean. The Web module is basically empty.

       

      The application.xml is:

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee" 
        xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd"
        id="Application_ID" version="6">
      
        <display-name>eartest</display-name>
      
        <initialize-in-order>true</initialize-in-order>
      
        <module>
          <web>
            <web-uri>eartestWeb.war</web-uri>
              <context-root>eartestWeb</context-root>
          </web>
        </module>
      
        <module>
          <ejb>eartestEJB.jar</ejb>
        </module>
      
      </application>
      
      

       

      The result from this is:

       

       

      16:28:25,226 INFO  [TomcatDeployment] deploy, ctxPath=/
      16:28:25,283 INFO  [BeanInstantiatorDeployerBase] Installed org.jboss.ejb3.instantiator.impl.Ejb31SpecBeanInstantiator@b4fb039 into MC at org.jboss.ejb.bean.instantiator/eartest/eartestEJB/MyBean
      16:28:25,291 WARN  [InterceptorInfoRepository] EJBTHREE-1852: InterceptorInfoRepository is deprecated
      16:28:25,678 INFO  [JBossASKernel] Created KernelDeployment for: eartestEJB.jar
      16:28:25,683 INFO  [JBossASKernel] installing bean: jboss.j2ee:ear=eartest.ear,jar=eartestEJB.jar,name=MyBean,service=EJB3
      16:28:25,683 INFO  [JBossASKernel]   with dependencies:
      16:28:25,683 INFO  [JBossASKernel]   and demands:
      16:28:25,683 INFO  [JBossASKernel] jboss.ejb:service=EJBTimerService; Required: Described
      16:28:25,683 INFO  [JBossASKernel] jboss-switchboard:appName=eartest,module=eartestEJB,name=MyBean; Required: Create
      16:28:25,683 INFO  [JBossASKernel]   and supplies:
      16:28:25,683 INFO  [JBossASKernel] jndi:MyBean
      16:28:25,687 INFO  [JBossASKernel] Added bean(jboss.j2ee:ear=eartest.ear,jar=eartestEJB.jar,name=MyBean,service=EJB3) to KernelDeployment of: eartestEJB.jar
      16:28:25,770 INFO  [SessionSpecContainer] Starting jboss.j2ee:ear=eartest.ear,jar=eartestEJB.jar,name=MyBean,service=EJB3
      16:28:25,776 INFO  [EJBContainer] STARTED EJB: test.MyBean ejbName: MyBean
      16:28:25,780 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
      
      
      16:28:25,782 WARN  [TimerServiceContainer] EJBTHREE-2193: using deprecated TimerServiceFactory for restoring timers
      16:28:26,258 INFO  [AbstractNoInterfaceViewBinder] Binding the following entry in Global JNDI for bean:MyBean
      
        eartest/MyBean/no-interface -> EJB3.1 no-interface view
      
      16:28:26,263 INFO  [TomcatDeployment] deploy, ctxPath=/eartestWeb
      16:28:26,317 INFO  [service] Removing bootstrap log handlers
      16:28:26,394 INFO  [org.apache.coyote.http11.Http11Protocol] Starting Coyote HTTP/1.1 on http-localhost%2F127.0.0.1-8080
      16:28:26,404 INFO  [org.apache.coyote.ajp.AjpProtocol] Starting Coyote AJP/1.3 on ajp-localhost%2F127.0.0.1-8009
      16:28:26,406 INFO  [org.jboss.bootstrap.impl.base.server.AbstractServer] JBossAS [6.0.0.Final "Neo"] Started in 19s:924ms
      
      

       

      If I reverse the order of the modules in application.xml, the startup log is as follows:

       

       

      16:30:35,759 INFO  [TomcatDeployment] deploy, ctxPath=/
      16:30:35,821 INFO  [BeanInstantiatorDeployerBase] Installed org.jboss.ejb3.instantiator.impl.Ejb31SpecBeanInstantiator@54170d32 into MC at org.jboss.ejb.bean.instantiator/eartest/eartestEJB/MyBean
      16:30:35,829 WARN  [InterceptorInfoRepository] EJBTHREE-1852: InterceptorInfoRepository is deprecated
      16:30:36,187 INFO  [JBossASKernel] Created KernelDeployment for: eartestEJB.jar
      16:30:36,190 INFO  [JBossASKernel] installing bean: jboss.j2ee:ear=eartest.ear,jar=eartestEJB.jar,name=MyBean,service=EJB3
      16:30:36,190 INFO  [JBossASKernel]   with dependencies:
      16:30:36,191 INFO  [JBossASKernel]   and demands:
      16:30:36,191 INFO  [JBossASKernel]           jboss.ejb:service=EJBTimerService; Required: Described
      16:30:36,191 INFO  [JBossASKernel]           jboss-switchboard:appName=eartest,module=eartestEJB,name=MyBean; Required: Create
      16:30:36,191 INFO  [JBossASKernel]   and supplies:
      16:30:36,191 INFO  [JBossASKernel]           jndi:MyBean
      16:30:36,195 INFO  [JBossASKernel] Added bean(jboss.j2ee:ear=eartest.ear,jar=eartestEJB.jar,name=MyBean,service=EJB3) to KernelDeployment of: eartestEJB.jar
      16:30:36,283 INFO  [SessionSpecContainer] Starting jboss.j2ee:ear=eartest.ear,jar=eartestEJB.jar,name=MyBean,service=EJB3
      16:30:36,289 INFO  [EJBContainer] STARTED EJB: test.MyBean ejbName: MyBean
      16:30:36,293 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
      
      
      16:30:36,295 WARN  [TimerServiceContainer] EJBTHREE-2193: using deprecated TimerServiceFactory for restoring timers
      16:30:36,793 INFO  [AbstractNoInterfaceViewBinder] Binding the following entry in Global JNDI for bean:MyBean
      
                eartest/MyBean/no-interface -> EJB3.1 no-interface view
      
      16:30:36,799 INFO  [TomcatDeployment] deploy, ctxPath=/eartestWeb
      16:30:36,855 INFO  [service] Removing bootstrap log handlers
      16:30:36,933 INFO  [org.apache.coyote.http11.Http11Protocol] Starting Coyote HTTP/1.1 on http-localhost%2F127.0.0.1-8080
      16:30:36,944 INFO  [org.apache.coyote.ajp.AjpProtocol] Starting Coyote AJP/1.3 on ajp-localhost%2F127.0.0.1-8009
      16:30:36,945 INFO  [org.jboss.bootstrap.impl.base.server.AbstractServer] JBossAS [6.0.0.Final "Neo"] Started in 21s:835ms
      
      

       

      As can be seen, there isn't any difference and the EJB module always seems to startup first.

        • 1. Re: initialize-in-order in application.xml honored?
          henk de boer Master

          To make the test a bit more explicit I added two "startup listeners":

           

          EJB

           

          @Singleton
          @Startup
          public class MyBean {
          
              @PostConstruct
              public void print() {
                  System.out.println("Test start EJB");
              }
          
          }
          
          

           

           

           

          WEB

           

          @WebListener
          public class MyListener implements ServletContextListener {
          
              @Override
              public void contextInitialized(ServletContextEvent arg0) {
                  System.out.println("Test start WEB");
              }
          
              @Override
              public void contextDestroyed(ServletContextEvent arg0) {}
          
          }
          
          

           

           

          With the web module listed before the ejb module in application.xml and initialize-in-order still set to true the output is:

           

          17:30:09,410 INFO  [STDOUT] Test start EJB
          17:30:09,417 INFO  [TomcatDeployment] deploy, ctxPath=/eartestWeb
          17:30:09,453 INFO  [STDOUT] Test start WEB
          
          
          • 2. initialize-in-order in application.xml honored?
            jaikiran pai Master

            The application_6.xsd says this about initialize-in-order:

             

            If initialize-in-order is true, modules must be initialized in the order they're listed in this deployment descriptor, with the exception of application client modules, which can be initialized in any order. If initialize-in-order is not set or set to false, the order of initialization is unspecified and may be product-dependent.

             

            Section EE.8.5.4 "Module Initialization" of JavaEE6 spec too has some more details. So the current behaviour looks like a bug. Please file a JIRA for this in the JBAS project.

            • 3. Re: initialize-in-order in application.xml honored?
              henk de boer Master

              jaikiran pai wrote:

               

              Section EE.8.5.4 "Module Initialization" of JavaEE6 spec too has some more details. So the current behaviour looks like a bug. Please file a JIRA for this in the JBAS project.

               

              Okay, I filed the issue here: https://issues.jboss.org/browse/JBAS-8839

               

              Thanks for looking into this.

              • 4. Re: initialize-in-order in application.xml honored?
                Ales Justin Master

                @Jaikiran: do we actually support this? I mean, is there some code that should handle this?

                 

                I know we fixed "strict order" in jboss-app.xml, which looks like similar functionality.

                Perhaps just "translating" -in-orded to our strict should do the trick.

                • 5. Re: initialize-in-order in application.xml honored?
                  jaikiran pai Master

                  Ales Justin wrote:

                   

                  @Jaikiran: do we actually support this? I mean, is there some code that should handle this?

                   

                  I don't think we have any code around this. At one point I remember Jason had done something similar to support the order of the modules (although I think it was for the jboss-app.xml strict order thing).

                   

                   

                  Ales Justin wrote:

                   

                   

                  I know we fixed "strict order" in jboss-app.xml, which looks like similar functionality.

                  Perhaps just "translating" -in-orded to our strict should do the trick.

                   

                  Right, that might work out. 

                  • 6. Re: initialize-in-order in application.xml honored?
                    Ales Justin Master

                     

                    I know we fixed "strict order" in jboss-app.xml, which looks like similar functionality.

                    Perhaps just "translating" -in-orded to our strict should do the trick.

                     

                    Right, that might work out. 

                    I've added this to AS6 trunk.

                     

                    EARStructure

                     

                                if (appMetaData.getModuleOrderEnum() == ModuleOrder.STRICT || (specMetaData instanceof Ear6xMetaData && ((Ear6xMetaData)specMetaData).getInitializeInOrder()))

                     

                    Can someone confirm that it does the job?