This is an automated email from the ASF dual-hosted git repository.

rmaucher pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 96c36eadea Undeploy missing context
96c36eadea is described below

commit 96c36eadeaa1313a71edbd4147a12d3b39663fcb
Author: remm <[email protected]>
AuthorDate: Wed Sep 2 20:44:46 2026 +0200

    Undeploy missing context
    
    Not sure it can really happen, but the code already handles some
    unlikely similar cases.
---
 java/org/apache/catalina/startup/HostConfig.java | 8 +++++++-
 java/org/apache/catalina/startup/UserConfig.java | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/startup/HostConfig.java 
b/java/org/apache/catalina/startup/HostConfig.java
index 79cf243f07..5472438dba 100644
--- a/java/org/apache/catalina/startup/HostConfig.java
+++ b/java/org/apache/catalina/startup/HostConfig.java
@@ -1328,7 +1328,13 @@ public class HostConfig implements LifecycleListener {
                         // The only resource that should be deleted is the
                         // expanded WAR (if any)
                         Context context = (Context) host.findChild(app.name);
-                        String docBase = context.getDocBase();
+                        String docBase = context == null ? null : 
context.getDocBase();
+                        if (context == null || docBase == null) {
+                            // Context missing or broken - redeploy instead of 
reload
+                            undeploy(app);
+                            deleteRedeployResources(app, resources, i, false);
+                            return;
+                        }
                         if 
(!docBase.toLowerCase(Locale.ENGLISH).endsWith(".war")) {
                             // This is an expanded directory
                             File docBaseFile = new File(docBase);
diff --git a/java/org/apache/catalina/startup/UserConfig.java 
b/java/org/apache/catalina/startup/UserConfig.java
index de8618395f..326a32f97d 100644
--- a/java/org/apache/catalina/startup/UserConfig.java
+++ b/java/org/apache/catalina/startup/UserConfig.java
@@ -363,6 +363,7 @@ public final class UserConfig implements LifecycleListener {
         try {
             Class<?> clazz = Class.forName(contextClass);
             Context context = (Context) clazz.getConstructor().newInstance();
+            // StandardContext or any compatible Context impl should also set 
the name derived from the path
             context.setPath(contextPath);
             context.setDocBase(app.toString());
             clazz = Class.forName(configClass);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to