You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2017/11/01 17:11:53 UTC

tomee git commit: TOMEE-2145 fix double deploy issue when deploying an EAR from the webapps directory

Repository: tomee
Updated Branches:
  refs/heads/master 63a43a5aa -> 108abf0ff


TOMEE-2145 fix double deploy issue when deploying an EAR from the webapps directory


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/108abf0f
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/108abf0f
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/108abf0f

Branch: refs/heads/master
Commit: 108abf0ff4f046238531129fb21a99f2ef76a433
Parents: 63a43a5
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Nov 1 17:09:07 2017 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Nov 1 17:09:07 2017 +0000

----------------------------------------------------------------------
 .../tomee/catalina/TomcatWebAppBuilder.java     | 25 ++++++++++++++++++++
 1 file changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/108abf0f/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 882f40a..760bea4 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
@@ -1147,6 +1147,10 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
             return;
         }
 
+        if (shouldNotDeploy(standardContext)) {
+            return;
+        }
+
         final CoreContainerSystem cs = getContainerSystem();
 
         final Assembler a = getAssembler();
@@ -1480,6 +1484,23 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
         realms.put(standardContext.getName(), realm);
     }
 
+    private static boolean shouldNotDeploy(StandardContext standardContext) {
+        if (StandardHost.class.isInstance(standardContext.getParent())) {
+            final StandardHost host = StandardHost.class.cast(standardContext.getParent());
+            if (host.getAutoDeploy() && new File(host.getAppBaseFile(), standardContext.getPath()).isDirectory() && (
+                    new File(host.getAppBaseFile(), standardContext.getPath() + ".ear").exists() ||
+                    new File(host.getAppBaseFile(), standardContext.getPath() + ".rar").exists())
+            ) {
+
+                logger.info(String.format("Not deploying exploded directory %s as Java EE artifact exists which will be deployed.",
+                        new File(host.getAppBaseFile(), standardContext.getPath()).getAbsolutePath()));
+
+                return true;
+            }
+        }
+        return false;
+    }
+
     public void setFinderOnContextConfig(final StandardContext standardContext, final AppModule appModule) {
         final OpenEJBContextConfig openEJBContextConfig = findOpenEJBContextConfig(standardContext);
         if (openEJBContextConfig != null) {
@@ -1662,6 +1683,10 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
             return;
         }
 
+        if (shouldNotDeploy(standardContext)) {
+            return;
+        }
+
         final Realm realm = standardContext.getRealm();
         final ClassLoader classLoader = standardContext.getLoader().getClassLoader();
         final Thread thread = Thread.currentThread();