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

markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 8cb18a6255 Follow-up to code review - lookup service consistently
8cb18a6255 is described below

commit 8cb18a62550b44712a1f7a983073acc4cfa2530a
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 39e2fc028e..28363b2e44 100644
--- a/java/org/apache/catalina/core/ApplicationContext.java
+++ b/java/org/apache/catalina/core/ApplicationContext.java
@@ -60,7 +60,6 @@ import jakarta.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;
@@ -96,7 +95,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 4f596ce916..cc060f74b3 100644
--- a/java/org/apache/catalina/manager/ManagerServlet.java
+++ b/java/org/apache/catalina/manager/ManagerServlet.java
@@ -425,9 +425,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