5 Replies Latest reply on Nov 12, 2012 4:53 AM by Saravanan Muthusamy

    Bootstrap a spring application context in JBoss AS7.1

    Saravanan Muthusamy Newbie

      We are migrating our application from JBoss AS5.1 to AS 7.1. my application consist of multiple(~100) sar files, I need a a centralized Bootstrap loader for loading the spring application context bundled in all the sar files. This was possible on AS5.1 with single Bootstrap class(my.prj.SpringBootstrapBean) bundled with my-core-app.jar and copied in to JBoss lib directory, all the sar files creates a mbean with this class in jboss-service.xml.

       

      my-core-app.jar -> my.prj.SpringBootstrapBean extends ServiceMBeanSupport

      class SpringBootstrapBean extends ServiceMBeanSupport{
           protected void startService() throws Exception { 
               ctx = new ClassPathXmlApplicationContext("META-INF/applicationContext.xml"); 
           }
       }
      

      my-comp1-app.sar { contents  META-INF/jboss-service.xml & META-INF/applicationContext.xml }

       

      and my jboss-service.xml looks like

       

      <?xml version="1.0" encoding="UTF-8"?>
      <server> 
          <mbean code="my.prj.SpringBootstrapBean"  name="my-app.comp1:service=bootstrap">
              <depends>my-app.comp:service=bootstrap</depends> 
          </mbean>
      </server>
      

      On AS5.1, when my-comp1-app.sar comes to deployment, SpringBootstrapBean located in lib dir was able to locate my "META-INF/applicationContext.xml" in the current sar file, as the TCCL was set. This is not possible in JBoss7 as my SpringBootstrapBean is always searching the spring context file in its class path (lib module).

       

      any idea how can i make a single bootstrap class to load my spring context ?