// @Override
private void startInternal(StandardContext standardContext) {
System.out.println("TomcatWebAppBuilder.start " + standardContext.getPath());
if (isIgnored(standardContext)) return;
CoreContainerSystem cs = getContainerSystem();
Assembler a = getAssembler();
if (a == null) {
logger.warning("OpenEJB has not been initialized so war will not be scanned for nested modules " + standardContext.getPath());
return;
}
AppContext appContext = null;
//Look for context info, maybe context is already scanned
ContextInfo contextInfo = getContextInfo(standardContext);
final ClassLoader classLoader = standardContext.getLoader().getClassLoader();
if (contextInfo == null) {
AppModule appModule = loadApplication(standardContext);
if (appModule != null) {
try {
contextInfo = addContextInfo(standardContext.getHostname(), standardContext);
AppInfo appInfo = configurationFactory.configureApplication(appModule);
contextInfo.appInfo = appInfo;
appContext = a.createApplication(contextInfo.appInfo, classLoader);
// todo add watched resources to context
} catch (Exception e) {
undeploy(standardContext, contextInfo);
logger.error("Unable to deploy collapsed ear in war " + standardContext.getPath() + ": Exception: " + e.getMessage(), e);
// just to force tomee to start without EE part
if (System.getProperty(TOMEE_EAT_EXCEPTION_PROP) == null) {
final TomEERuntimeException tre = new TomEERuntimeException(e);
DeploymentExceptionManager dem = SystemInstance.get().getComponent(DeploymentExceptionManager.class);
dem.saveDelpoyementException(contextInfo.appInfo, tre);
throw tre;
}
return;
}
}
}
if (appContext == null) {
String contextRoot = standardContext.getName();
if (contextRoot.startsWith("/")) {
contextRoot = contextRoot.replaceAll("^/+", "");
}
}
contextInfo.standardContext = standardContext;
WebAppInfo webAppInfo = null;
// appInfo is null when deployment fails
if (contextInfo.appInfo != null) {
for (WebAppInfo w : contextInfo.appInfo.webApps) {
if (("/" + w.contextRoot).equals(standardContext.getPath()) || isRootApplication(standardContext)) {
webAppInfo = w;
if (appContext == null) {
appContext = cs.getAppContext(contextInfo.appInfo.appId);
}
break;
}
}
}
if (webAppInfo != null) {
if (appContext == null) {
appContext = getContainerSystem().getAppContext(contextInfo.appInfo.appId);
}
try {
// determine the injections
final Set<Injection> injections = new HashSet<Injection>();
injections.addAll(appContext.getInjections());
injections.addAll(new InjectionBuilder(classLoader).buildInjections(webAppInfo.jndiEnc));
// jndi bindings
final Map<String, Object> bindings = new HashMap<String, Object>();
bindings.putAll(appContext.getBindings());
bindings.putAll(getJndiBuilder(classLoader, webAppInfo, injections).buildBindings(JndiEncBuilder.JndiScope.comp));
// merge OpenEJB jndi into Tomcat jndi
final TomcatJndiBuilder jndiBuilder = new TomcatJndiBuilder(standardContext, webAppInfo, injections);
jndiBuilder.mergeJndi();
// add WebDeploymentInfo to ContainerSystem
final WebContext webContext = new WebContext(appContext);
webContext.setClassLoader(classLoader);
webContext.setId(webAppInfo.moduleId);
webContext.setBindings(bindings);
webContext.getInjections().addAll(injections);
appContext.getWebContexts().add(webContext);
cs.addWebContext(webContext);
standardContext.setInstanceManager(new JavaeeInstanceManager(webContext, standardContext));
standardContext.getServletContext().setAttribute(InstanceManager.class.getName(), standardContext.getInstanceManager());
} catch (Exception e) {