Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 619
Hardik Vadodariya Avatar asked Oct 18 '22 15:10

Hardik Vadodariya


1 Answers

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.
like image 122
Piotr Kuciapski Avatar answered Oct 21 '22 06:10

Piotr Kuciapski