Skip to content

Tomcat JBP_CONFIG_TOMCAT context_path not applied in v5 #1331

Description

@dion-ict

When updating from buildpack v4.77.0 to v5.0.4, using the context_path configuration mentioned here:
https://github.com/cloudfoundry/java-buildpack/blob/main/docs/container-tomcat.md#common-configurations

is no longer applied for Tomcat, resulting in otherwise working deployment under '/' instead.

Environment:

  • java buildpack 5.0.4
  • Tomcat 9 or 10
  • Java 21

What happens is that in the Finalizing Tomcat step, a ROOT.xml containing correct docBase is created under deps/0/tomcat/conf/Catalina/localhost resulting in deployment under / :

   2026-06-24T12:13:56.74+0200 [STG/0] OUT -----> Supplying Tomcat
   2026-06-24T12:13:56.74+0200 [STG/0] OUT Tomcat version not specified
   2026-06-24T12:13:56.74+0200 [STG/0] OUT Using Tomcat 10.x for Java 21
   2026-06-24T12:13:56.74+0200 [STG/0] OUT -----> Installing tomcat 10.1.55
   2026-06-24T12:13:56.74+0200 [STG/0] OUT Copy [/tmp/cache/final/dependencies/cf3d51db4f0d9e47ef1af1556814bdd88f99ce384ab0bcf273cb8c6cbc065e04/tomcat_10.1.55_linux_noarch_any-stack_978a0d08.tgz]
   2026-06-24T12:13:57.08+0200 [STG/0] OUT Installed Tomcat (10.1.55)
   2026-06-24T12:13:57.08+0200 [STG/0] OUT Access logging disabled by default (use JBP_CONFIG_TOMCAT to enable)
   2026-06-24T12:13:57.08+0200 [STG/0] OUT -----> Installing tomcat-lifecycle-support 3.4.0
   2026-06-24T12:13:57.08+0200 [STG/0] OUT Copy [/tmp/cache/final/dependencies/323b4998dc556969506d4ddd8ecae3e353a3dc47c5df68e15e340fd4bda92914/tomcat-lifecycle-support-3.4.0-RELEASE.jar]
   2026-06-24T12:13:57.08+0200 [STG/0] OUT Successfully installed Tomcat Lifecycle Support 3.4.0 to tomcat/lib
   2026-06-24T12:13:57.08+0200 [STG/0] OUT -----> Installing tomcat-access-logging-support 3.4.0
   2026-06-24T12:13:57.08+0200 [STG/0] OUT Copy [/tmp/cache/final/dependencies/8b8f55fd2576eb3a77033eac2511cc9331f7e9f5b99b2481e7ab5ea9601faab8/tomcat-access-logging-support-3.4.0-RELEASE.jar]
   2026-06-24T12:13:57.08+0200 [STG/0] OUT Successfully installed Tomcat Access Logging Support 3.4.0 to tomcat/lib
   2026-06-24T12:13:57.08+0200 [STG/0] OUT -----> Installing tomcat-logging-support 3.4.0
   2026-06-24T12:13:57.08+0200 [STG/0] OUT Copy [/tmp/cache/final/dependencies/93f8b9300953402ec8a55818b7f21de69e7d716186c14f17daaf2361bf629112/tomcat-logging-support-3.4.0-RELEASE.jar]
   2026-06-24T12:13:57.08+0200 [STG/0] OUT Successfully installed Tomcat Logging Support 3.4.0 to tomcat/bin (contains CloudFoundryConsoleHandler)
   2026-06-24T12:13:57.08+0200 [STG/0] OUT Created setenv.sh with logging JAR on boot classpath
   2026-06-24T12:13:57.08+0200 [STG/0] OUT Installing Cloud Foundry-optimized Tomcat configuration defaults
   2026-06-24T12:13:57.08+0200 [STG/0] OUT Installed default server.xml to /tmp/contents2414969076/deps/0/tomcat/conf/server.xml
   2026-06-24T12:13:57.08+0200 [STG/0] OUT Installed default logging.properties to /tmp/contents2414969076/deps/0/tomcat/conf/logging.properties
   2026-06-24T12:13:57.08+0200 [STG/0] OUT Installed default context.xml to /tmp/contents2414969076/deps/0/tomcat/conf/context.xml
   2026-06-24T12:13:57.08+0200 [STG/0] OUT Tomcat configuration includes:
   2026-06-24T12:13:57.08+0200 [STG/0] OUT - Dynamic port binding (${http.port} from $PORT)
   2026-06-24T12:13:57.08+0200 [STG/0] OUT - HTTP/2 support enabled
   2026-06-24T12:13:57.08+0200 [STG/0] OUT - RemoteIpValve for X-Forwarded-* headers
   2026-06-24T12:13:57.08+0200 [STG/0] OUT - CloudFoundryAccessLoggingValve with vcap_request_id
   2026-06-24T12:13:57.08+0200 [STG/0] OUT - Stdout logging via CloudFoundryConsoleHandler
   2026-06-24T12:13:57.10+0200 [STG/0] OUT -----> Running go build finalize
   2026-06-24T12:13:58.45+0200 [STG/0] OUT Loaded supply config: container=Tomcat jre=OpenJDK version=21.0.11+11
   2026-06-24T12:13:58.45+0200 [STG/0] OUT -----> Finalizing Java
   2026-06-24T12:13:58.45+0200 [STG/0] OUT Finalizing container: Tomcat
   2026-06-24T12:13:58.45+0200 [STG/0] OUT -----> Finalizing JRE: OpenJDK
   2026-06-24T12:13:58.45+0200 [STG/0] OUT Configuring JVMKill Agent
   2026-06-24T12:13:58.55+0200 [STG/0] OUT Configuring Memory Calculator
   2026-06-24T12:13:58.55+0200 [STG/0] OUT -----> Finalizing frameworks [Client Certificate Mapper, Container Security Provider, Java Opts]
   2026-06-24T12:13:58.55+0200 [STG/0] OUT Configured Container Security Provider for runtime (priority 17)
   2026-06-24T12:13:58.55+0200 [STG/0] OUT -----> Configuring Java Opts
   2026-06-24T12:13:58.55+0200 [STG/0] OUT Configured user JAVA_OPTS for runtime (priority 99)
   2026-06-24T12:13:58.55+0200 [STG/0] OUT -----> Finalizing Tomcat
   2026-06-24T12:13:58.55+0200 [STG/0] OUT Created ROOT.xml with docBase pointing to application directory

How to reproduce:

workaround:
SSH into the instance and renaming ROOT.xml to the#intended#path.xml results in reload within Tomcat and exposing under the desired web context path /the/intended/path/ .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions