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

markt-asf 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 a3308112e0 Follow-up to code review - lookup service consistently
a3308112e0 is described below

commit a3308112e0aa4bd8ef4827db5083616f880f8401
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Jun 22 22:47:09 2026 +0100

    Follow-up to code review - lookup service consistently
---
 java/org/apache/catalina/core/ApplicationContext.java | 3 +--
 java/org/apache/catalina/manager/ManagerServlet.java  | 9 ++++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/core/ApplicationContext.java 
b/java/org/apache/catalina/core/ApplicationContext.java
index 298bd60fdb..046a77757e 100644
--- a/java/org/apache/catalina/core/ApplicationContext.java
+++ b/java/org/apache/catalina/core/ApplicationContext.java
@@ -59,7 +59,6 @@ import javax.servlet.http.HttpSessionListener;
 
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
 import org.apache.catalina.Globals;
 import org.apache.catalina.LifecycleState;
 import org.apache.catalina.Service;
@@ -112,7 +111,7 @@ public class ApplicationContext implements ServletContext {
     public ApplicationContext(StandardContext context) {
         super();
         this.context = context;
-        this.service = ((Engine) context.getParent().getParent()).getService();
+        this.service = Container.getService(context);
         this.sessionCookieConfig = new ApplicationSessionCookieConfig(context);
 
         // Populate session tracking modes
diff --git a/java/org/apache/catalina/manager/ManagerServlet.java 
b/java/org/apache/catalina/manager/ManagerServlet.java
index b1a653c148..2c88dab403 100644
--- a/java/org/apache/catalina/manager/ManagerServlet.java
+++ b/java/org/apache/catalina/manager/ManagerServlet.java
@@ -422,9 +422,12 @@ public class ManagerServlet extends HttpServlet implements 
ContainerServlet {
         }
 
         // Acquire global JNDI resources if available
-        Server server = ((Engine) host.getParent()).getService().getServer();
-        if (server != null) {
-            global = server.getGlobalNamingContext();
+        Service service = Container.getService(host);
+        if (service != null) {
+            Server server = service.getServer();
+            if (server != null) {
+                global = server.getGlobalNamingContext();
+            }
         }
 
         // Calculate the directory into which we will be deploying applications


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

Reply via email to