try { readConfigurationFile();  configureAddress();  toUnbindAtExit.clear();  jndiNamingFactory = System.getProperty("java.naming.factory.initial");   try { NamingManager. setInitialContextFactoryBuilder(new InVMInitialContextFactoryBuilder()); } catch(IllegalStateException e) {  }  Hashtable t = InVMInitialContextFactory.getJNDIEnvironment(serverIndex); System.setProperty("java.naming.factory.initial", (String)t.get("java.naming.factory.initial")); System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME, Integer.toString(serverIndex));  initialContext = new InitialContext();  boolean java5 = false;  try { ClassLoader cl = Thread.currentThread().getContextClassLoader(); cl.loadClass("java.lang.management.ManagementFactory"); java5 = true; } catch(ClassNotFoundException e) {  }  if (java5) { System.setProperty("javax.management.builder.initial", "org.jboss.test.messaging.tools.jmx.MBeanServerBuilder"); }  mbeanServer = MBeanServerFactory.createMBeanServer("jboss");  serviceCreator = new ServiceCreator(mbeanServer);  startServiceController();  registerClassLoader();  if (transaction) { startTransactionManager(); } if (database) { startInVMDatabase(); } if (jca) { startCachedConnectionManager(CACHED_CONNECTION_MANAGER_OBJECT_NAME);   startManagedConnectionFactory(DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME); startManagedConnectionPool(DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME, DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME, "ByContainer"); startConnectionManager(DEFAULTDS_CONNECTION_MANAGER_OBJECT_NAME, true, true, TRANSACTION_MANAGER_OBJECT_NAME, CachedConnectionManagerMBean.OBJECT_NAME, DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME); startWrapperDataSourceService(); }  if (remoting) { startRemoting(); }  if (security) { startSecurityManager(); }  if (database && transaction && jca) {   deleteAllData(); } else { if (database) { log.warn("Previous data has not been cleared, there may be " + "" + "garbage lying around in the database!"); } }  loadJNDIContexts();  log.debug("loaded JNDI context");  String transport = config.getRemotingTransport();  log.info("Remoting type: ........... " + (remoting ? transport : "DISABLED")); log.info("Serialization type: ...... " + config.getSerializationType()); log.info("Database: ................ " + config.getDatabaseType()); log.info("Clustering mode: ......... " + (this.isClustered() ? "CLUSTERED" : "NON-CLUSTERED"));  log.debug(this + " started"); } catch(Throwable e) { log.error("Failed to start ServiceContainer", e); throw new Exception("Failed to start ServiceContainer", e); }
start(true);
   public void start() throws Exception   {      try      {         readConfigurationFile();         configureAddress();         toUnbindAtExit.clear();         jndiNamingFactory = System.getProperty("java.naming.factory.initial");         //TODO: need to think more about this; if I don't do it, though, bind() fails because it tries to use "java.naming.provider.url"         try         {            NamingManager.               setInitialContextFactoryBuilder(new InVMInitialContextFactoryBuilder());         }         catch(IllegalStateException e)         {            // OK         }         Hashtable t = InVMInitialContextFactory.getJNDIEnvironment(serverIndex);         System.setProperty("java.naming.factory.initial",                            (String)t.get("java.naming.factory.initial"));         System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME,                            Integer.toString(serverIndex));         initialContext = new InitialContext();         boolean java5 = false;         try         {            ClassLoader cl = Thread.currentThread().getContextClassLoader();            cl.loadClass("java.lang.management.ManagementFactory");            java5 = true;         }         catch(ClassNotFoundException e)         {            // OK         }         if (java5)         {            System.setProperty("javax.management.builder.initial",                               "org.jboss.test.messaging.tools.jmx.MBeanServerBuilder");         }         mbeanServer = MBeanServerFactory.createMBeanServer("jboss");         serviceCreator = new ServiceCreator(mbeanServer);         startServiceController();         registerClassLoader();         if (transaction)         {            startTransactionManager();         }         if (database)         {            startInVMDatabase();         }         if (jca)         {            startCachedConnectionManager(CACHED_CONNECTION_MANAGER_OBJECT_NAME);            // DefaultDS specific            startManagedConnectionFactory(DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME);            startManagedConnectionPool(DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME,                                       DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME,                                       "ByContainer");            startConnectionManager(DEFAULTDS_CONNECTION_MANAGER_OBJECT_NAME, true, true,                                   TRANSACTION_MANAGER_OBJECT_NAME,                                   CachedConnectionManagerMBean.OBJECT_NAME,                                   DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME);            startWrapperDataSourceService();         }         if (remoting)         {            startRemoting();         }         if (security)         {            startSecurityManager();         }         if (database && transaction && jca)         {            // We make sure the database is clean (only if we have all dependencies the database,            // othewise we'll get an access error)            deleteAllData();         }         else         {            if (database)            {               log.warn("Previous data has not been cleared, there may be " + "" +                        "garbage lying around in the database!");            }         }         loadJNDIContexts();         log.debug("loaded JNDI context");         String transport = config.getRemotingTransport();         log.info("Remoting type: ........... " + (remoting ? transport : "DISABLED"));         log.info("Serialization type: ...... " + config.getSerializationType());         log.info("Database: ................ " + config.getDatabaseType());         log.info("Clustering mode: ......... " +            (this.isClustered() ? "CLUSTERED" : "NON-CLUSTERED"));         log.debug(this + " started");      }      catch(Throwable e)      {         log.error("Failed to start ServiceContainer", e);         throw new Exception("Failed to start ServiceContainer", e);      }   }