Openshift update java 7 to 8 in Tomcat 7 (JBoss EWS 2.0) Cartridge

1.3k views Asked by At

I am new to Openshift and i have created a server instance using Tomcat 7 (JBoss EWS 2.0) cartridge for my spring boot web application.

Initially, web application was using JDK7 and was working fine on Openshift. Now for some enhancement we have to switch to JDK8.

I tried searching on Google about changing JAVA_HOME to JDK8 and i tried most of the solutions but i can not make it work.

  • Tried Solution 1: Created start file under app-root/runtime/repo/.openshift/action_hooks/ with below content.

    #!/bin/bash export JAVA_HOME=/etc/alternatives/java_sdk_1.8.0 export PATH=$JAVA_HOME:$PATH

    Also, the file has +x permission.

  • Tried Solution 2: Created java8 marker under app-root/runtime/repo/.openshift/markers and jbossews/template/.openshift/markers.

The above solutions don't work. Other option is DIY cartridge which may work but i don't want to create new application and move everything there.

EDIT

Below is the directory structure

Directory Structure

Please note that i have created this application using open shift UI and not using rhc command.

Please guide me.

Thanks

2

There are 2 answers

2
K.Nicholas On

Sounds like bad planning: You're supposed to that your platform supports Java-8 before writing code that requires it. From the Openshift documentation:

3.2. Java Environments Supported By JBoss Enterprise Application Platform 6 JBoss Enterprise Application Platform 6 requires Java 6 or Java 7. The list of supported Java environments can be found at http://www.jboss.com/products/platforms/application/supportedconfigurations/. A Java Development Kit (JDK) is required for development, and a Java Runtime Environment (JRE) is required to run JBoss Enterprise Application Platform.

2
Piotr Kuciapski On

I had to "cheat" a little to enable java 8, since the "java8" marker doesn't seem to work. Look at the JbossEWS cartridge source:

function export_java_home() {
  if marker_present "java7"; then
    export JAVA_HOME=$OPENSHIFT_JBOSSEWS_JDK7
  else
    export JAVA_HOME=$OPENSHIFT_JBOSSEWS_JDK6
  fi
}

So, my solution/workaround is:

  • Set your OPENSHIFT_JBOSSEWS_JDK7 environment var to point to jdk8 instead of jdk7:
rhc env set OPENSHIFT_JBOSSEWS_JDK7="/etc/alternatives/java_sdk_1.8.0" -a YOURAPPNAME
  • Add the java7 marker to your .openshift/markers directory.