简体   繁体   中英

Cloud Foundry Java Buildpack : how to change value in server.xml for Tomcat?

I want to override the value maxPostSize property in the Connector element in the server.xml configuration file. (Set the maximum size to 1MB)

Is the only way to do this to fork the https://github.com/cloudfoundry/java-buildpack and change the existing server.xml configuration file ?

Or is it also possible to add a server.xml somewhere in my WAR file, so that this one will be used instead of the one which is present in the buildpack.

Or can I also use JAVA_OPTS for that ?

Is the only way to do this to fork the https://github.com/cloudfoundry/java-buildpack and change the existing server.xml configuration file ?

With version 3.7+ of the Java build pack you can override the Tomcat configuration without forking the build pack. The feature is called "External Tomcat Configuration".

https://github.com/cloudfoundry/java-buildpack/blob/master/docs/container-tomcat.md#external-tomcat-configuration

Here's the gist of how it works.

  • You make a TAR file of your tomcat/conf directory. This can contain things like server.xml , context.xml , web.xml and anything that would normally go under Tomcat's conf/ directory.
  • You host an index.yml and that TAR file on an HTTP server some where. If you don't have one, you can push it as an application to CF using the Static File build pack.
  • You point the Java build pack to this configuration repo with the environment variable JBP_CONFIG_TOMCAT . Here is an example: `"{ tomcat: { external_configuration_enabled: true }, external_configuration: { repository_root: \\"url_to_repo\\" } }"

More on the structure for the files on the HTTP server can be found here

I believe this will document all of your official options: https://github.com/cloudfoundry/java-buildpack/blob/master/docs/container-tomcat.md#additional-resources

Neither of which are very simple/easy.

You could consider changing your application to a spring boot application. I'm not a boot expert but I believe that the java buildpack can use a boot embedded tomcat even even if the packaging type is a .war. In this type of configuration you might be able to use boot to customize how it starts the embedded tomcat to customize things like maxPostSize.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM