385317 - Synchronize the initialization of enterprise container for apps
diff --git a/org.eclipse.virgo.web.enterprise.applistener/src/main/java/org/eclipse/virgo/web/enterprise/applistener/internal/OpenEjbApplicationListener.java b/org.eclipse.virgo.web.enterprise.applistener/src/main/java/org/eclipse/virgo/web/enterprise/applistener/internal/OpenEjbApplicationListener.java
index 2e67cb3..d845694 100755
--- a/org.eclipse.virgo.web.enterprise.applistener/src/main/java/org/eclipse/virgo/web/enterprise/applistener/internal/OpenEjbApplicationListener.java
+++ b/org.eclipse.virgo.web.enterprise.applistener/src/main/java/org/eclipse/virgo/web/enterprise/applistener/internal/OpenEjbApplicationListener.java
@@ -26,7 +26,9 @@
import org.slf4j.LoggerFactory;
public class OpenEjbApplicationListener implements LifecycleListener {
-
+ // globally synchronize deployment because of overlapping app data
+ private static Object monitor = new Object();
+
private final Logger logger = LoggerFactory.getLogger(this.getClass());
public void deploy(StandardContext standardContext) throws Exception {
@@ -34,12 +36,13 @@
String contextPath = context.getContextPath();
VirgoDeployerEjb deployer = new VirgoDeployerEjb(contextPath, context.getClassLoader());
try {
-
String realPath = context.getRealPath("");
- if (realPath != null) {
- deployer.deploy(realPath, standardContext);
- } else {
- deployer.deploy(getAppModuleId(standardContext.getDocBase()), standardContext);
+ synchronized (monitor) {
+ if (realPath != null) {
+ deployer.deploy(realPath, standardContext);
+ } else {
+ deployer.deploy(getAppModuleId(standardContext.getDocBase()), standardContext);
+ }
}
} catch (Exception e) {
if (logger.isErrorEnabled()) {
@@ -47,9 +50,9 @@
}
throw e;
}
-
}
+ // no need to synchronize the undeploy operation as it is stateless
public void undeploy(StandardContext standardContext) throws Exception {
ServletContext context = standardContext.getServletContext();
String contextPath = context.getContextPath();