Pivotal Knowledge Base

Follow

How do I use an older version of Java or Apache Tomcat with my Java app?

Purpose

You have a Java or alternative JVM language application that you want to deploy on PWS.  By default, the Java build pack for PWS will deploy your application using Java 8 and Tomcat 8.  You'd like to use a previous version of Java or Tomcat.

Instructions

It is possible to change the version of Java and Tomcat.  See the section below for changing the Java or Tomcat version.

Java

To change the version of Java, you need to set the environment variable JBP_CONFIG_OPEN_JDK_JRE to '[version: 1.7.0_+]'  and restage the application.  When the build pack runs, it will see this environment variable and install the latest version of Java 7.  For more details on the format of the version number, please see the docs here.  A full list of the supported versions can be found here.

Ex:  manifest.yml

---
applications:
- name: spring-music
  memory: 512M
  instances: 1
  path: build/libs/spring-music.war
  env:
    JBP_CONFIG_OPEN_JDK_JRE: '[version: 1.7.0_+]'

Ex:  cf set-env

cf set-env spring-music JBP_CONFIG_OPEN_JDK_JRE '[version: 1.7.0_+]'

Tomcat

To change the version of Apache Tomcat, you need to set the environment variable JBP_CONFIG_TOMCAT to '[tomcat: { version: 7.0.+ }]' and restage the application.  When the build pack runs, it will see this environment variable and install the latest version of Apache Tomcat 7.  For more details on the format of the version number, please see the docs here.  A full list of the supported versions can be found here.

Ex:  manifest.yml

---
applications:
- name: spring-music
  memory: 512M
  instances: 1
  host: spring-music-${random-word}
  path: build/libs/spring-music.war
  env:
    JBP_CONFIG_TOMCAT: '[tomcat: { version: 7.0.+ }]'

Ex:  cf set-env

cf set-env spring-music JBP_CONFIG_TOMCAT '[tomcat: { version: 7.0.+ }]'

Additional Information

If you would like to revert the changes above, you simply need to remove the environment variables and restage the app.  You can do that with the steps below.

  1. Remove any JBP_CONFIG_* environment variables from your manifest.yml file.
  2. Run cf unset-env <app> JBP_CONFIG_OPEN_JDK_JRE to remove a custom Java version or cf unset-env <app> JBP_CONFIG_OPEN_JDK_JRE to remove a custom Tomcat version.
  3. Run cf restage <app>.  This will restage the application which will cause the build pack to update the Java or Tomcat version.

Impact / Risks

By default, the Java build pack will automatically select the most recent minor version of the components that it uses.  This includes selecting the latest minor version of Java and Tomcat (this happens even if you fork the build pack).  This behavior is important as it keep your application up-to-date with the latest security and bug fixes for the components.  If you use the instructions above to select a fixed or older major version of a component, you will disable this behavior.  We do not recommend doing this as it could leave you vulnerable to known security problems with the software.

Comments

Powered by Zendesk