Repository: tomee Updated Branches: refs/heads/master 1f9fdc9f6 -> fc806570f
TOMEE-1568 support overriding of a failed deployment in tomcat webappdeployer Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/fc806570 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/fc806570 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/fc806570 Branch: refs/heads/master Commit: fc806570f880036d9103ff25e0ec07ebaa30cc7d Parents: 1f9fdc9 Author: Romain Manni-Bucau <rmannibu...@apache.org> Authored: Wed Apr 29 22:59:17 2015 +0200 Committer: Romain Manni-Bucau <rmannibu...@apache.org> Committed: Wed Apr 29 22:59:17 2015 +0200 ---------------------------------------------------------------------- .../org/apache/openejb/assembler/DeployerEjb.java | 7 +++++-- .../apache/tomee/catalina/TomcatWebAppBuilder.java | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/fc806570/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java index 908d14b..bc4d354 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java @@ -176,8 +176,11 @@ public class DeployerEjb implements Deployer { try { final AppInfo appInfo = SystemInstance.get().getComponent(WebAppDeployer.class) .deploy(host, contextRoot(properties, file.getAbsolutePath()), file); - saveIfNeeded(properties, file, appInfo); - return appInfo; + if (appInfo != null) { + saveIfNeeded(properties, file, appInfo); + return appInfo; + } + throw new OpenEJBException("can't deploy " + file.getAbsolutePath()); } finally { AUTO_DEPLOY.remove(); } http://git-wip-us.apache.org/repos/asf/tomee/blob/fc806570/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java ---------------------------------------------------------------------- diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java index 1f9c81a..c98ef26 100644 --- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java +++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java @@ -466,7 +466,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare } } - if (getContextInfo(webApp.host, webApp.contextRoot) != null) { + if (isAlreadyDeployed(webApp)) { continue; } @@ -515,7 +515,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare appParam.setValue(webApp.moduleId); standardContext.addApplicationParameter(appParam); - if (getContextInfo(webApp.host, webApp.contextRoot) == null) { + if (!isAlreadyDeployed(webApp)) { if (standardContext.getPath() == null) { if (webApp.contextRoot != null && webApp.contextRoot.startsWith("/")) { standardContext.setPath(webApp.contextRoot); @@ -542,7 +542,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare webApp.contextRoot = ""; } - if (getContextInfo(webApp.host, webApp.contextRoot) != null) { // possible because of the previous renaming + if (isAlreadyDeployed(webApp)) { // possible because of the previous renaming continue; } @@ -580,6 +580,17 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare } } + private boolean isAlreadyDeployed(final WebAppInfo webApp) { + final ContextInfo contextInfo = getContextInfo(webApp.host, webApp.contextRoot); + if (contextInfo != null && contextInfo.standardContext != null && contextInfo.standardContext.getState() == LifecycleState.FAILED) { + synchronized (this) { + infos.remove(getId(webApp.host, webApp.contextRoot)); + } + return false; + } + return contextInfo != null; + } + private static boolean isParent(final ClassLoader parent, final ClassLoader child) { ClassLoader current = child; while (current != null) {