} finally { Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
    public ServiceUnit deploy(String serviceUnitName, String serviceUnitRootPath) throws DeploymentException {        Kernel kernel = KernelFactory.newInstance().createKernel(component.getComponentName() + "/" + serviceUnitName);        try {            // Create service unit            XBeanServiceUnit su = new XBeanServiceUnit();            su.setKernel(kernel);            su.setComponent(component);            su.setName(serviceUnitName);            su.setRootPath(serviceUnitRootPath);            // Load configuration            Thread.currentThread().setContextClassLoader(getClass().getClassLoader());            FileSystemRepository repository = new FileSystemRepository(new File(serviceUnitRootPath));            ClassLoaderXmlPreprocessor classLoaderXmlPreprocessor = new ClassLoaderXmlPreprocessor(repository);            List xmlPreprocessors = Collections.singletonList(classLoaderXmlPreprocessor);            SpringLoader springLoader = new SpringLoader();            springLoader.setKernel(kernel);            springLoader.setBaseDir(new File(serviceUnitRootPath));            springLoader.setXmlPreprocessors(xmlPreprocessors);                        PropertyPlaceholderConfigurer propertyPlaceholder = new PropertyPlaceholderConfigurer();			FileSystemResource propertiesFile = new FileSystemResource(					new File(serviceUnitRootPath) + "/" + getXBeanFile()							+ ".properties");			if (propertiesFile.getFile().exists()) {								propertyPlaceholder.setLocation(propertiesFile);				springLoader.setBeanFactoryPostProcessors(Collections						.singletonList(propertyPlaceholder));			} 			            ServiceName configurationName = springLoader.load(getXBeanFile());            kernel.startService(configurationName);            su.setConfiguration(configurationName);            // Retrieve endpoints            List services = getServices(kernel);            if (services == null || services.size() == 0) {                throw failure("deploy", "No endpoints found", null);            }            for (Iterator iter = services.iterator(); iter.hasNext();) {                Endpoint endpoint = (Endpoint) iter.next();                endpoint.setServiceUnit(su);                if (validate(endpoint)) {                    su.addEndpoint(endpoint);                } else {                    logger.warn("Endpoint " + endpoint + "has not been validated");                }            }            if (su.getEndpoints().size() == 0) {                throw failure("deploy", "No endpoint found", null);            }            return su;        } catch (Exception e) {            kernel.destroy();            if (e instanceof DeploymentException) {                throw ((DeploymentException) e);            } else {                throw failure("deploy", "Could not deploy xbean service unit", e);            }        }    }