} else {
path += "/" + standardContext.getPath();
}
}
WebContext webContext = cs.getWebContext(path);
if (webContext == null) { // tomee-embedded deployment
webContext = cs.getWebContext(standardContext.getPath().replaceFirst("/", ""));
if (webContext == null) {
webContext = cs.getWebContext(standardContext.getPath());
}
}
if (webContext != null && webContext.getBindings() != null) {
for (Map.Entry<String, Object> entry : webContext.getBindings().entrySet()) {
try {
final String key = entry.getKey();
Object value = normalize(entry.getValue());
Contexts.createSubcontexts(root, key);
root.rebind(key, value);
} catch (NamingException e) {
e.printStackTrace();
}
}
}
// try to force some binding which probably failed earlier (see in TomcatWebappBuilder)
try {
Context comp = (Context) ContextBindings.getClassLoader().lookup("comp");
TransactionManager transactionManager = SystemInstance.get().getComponent(TransactionManager.class);
comp.rebind("TransactionManager", transactionManager);
// bind TransactionSynchronizationRegistry
TransactionSynchronizationRegistry synchronizationRegistry = SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class);
comp.rebind("TransactionSynchronizationRegistry", synchronizationRegistry);
comp.rebind("ORB", new SystemComponentReference(ORB.class));
comp.rebind("HandleDelegate", new SystemComponentReference(HandleDelegate.class));
if (webContext != null) {
comp.rebind("BeanManager", webContext.getAppContext().getBeanManager());
}
} catch (Exception ignored) {
ignored.printStackTrace();
// no-op
}