Bug 1009152 - JBoss cartridges are not using env variables to determine JAVA_HOME
JBoss cartridges are not using env variables to determine JAVA_HOME
Status: CLOSED ERRATA
Product: OpenShift Container Platform
Classification: Red Hat
Component: Containers (Show other bugs)
1.2.1
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Brenton Leanhardt
libra bugs
:
Depends On: 1004927
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-17 15:43 EDT by John Keck
Modified: 2017-03-08 12 EST (History)
9 users (show)

See Also:
Fixed In Version: openshift-origin-cartridge-jbosseap-2.3.11.3-1.git.0.4d0ae9b.el6op, openshift-origin-cartridge-jbossews-0.4.11-1.git.0.727562d.el6op
Doc Type: Bug Fix
Doc Text:
Due to a bug in the EAP and EWS cartridges, the JAVA_HOME environment variable got overridden by marker files. This fix allows the JAVA_HOME environment variable to be read from the environment, resulting in a more consistent user experience.
Story Points: ---
Clone Of: 1004927
Environment:
Last Closed: 2013-10-16 11:39:16 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description John Keck 2013-09-17 15:43:23 EDT
+++ This bug was initially created as a clone of Bug #1004927 +++

Description of problem:
All of the cartridge scripts should use the values from OPENSHIFT_JBOSSEAP_JDK7/6 when setting JAVA_HOME.  Currently is it possible for a cartridge and the JBoss container to use different jvm's.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Review standalone.conf
2.
3.

Actual results:
Cartridge sets /etc/alternatives path while standalone.conf uses /usr/lib/jvm path

Expected results:
Use same jvm path from /etc/alternatives

Additional info:

--- Additional comment from Nikhil Mone on 2013-09-06 06:35:49 EDT ---

Putting some additional info, which might help to prioritize and quick fix the bug :


==== standalone.conf =======
# This uses the sun jdk install since the current open-jdk version has a bug
# Once this has been upgrade to something based on 1.6.0_20 or higher,
# such as java-1.6.0-openjdk-1.6.0.0-1.39.1.9.7.el6, require the sun jdk.
if [ -e ${OPENSHIFT_REPO_DIR}.openshift/markers/java7 ];
then
        JAVA_HOME="/usr/lib/jvm/jre-1.7.0"
else
        JAVA_HOME="/usr/lib/jvm/jre-1.6.0"
fi
============================

Now there is  series of symlinks :

$ ls -la /usr/lib/jvm/jre-1.7.0
lrwxrwxrwx. 1 root root 27 Aug 28 10:57 /usr/lib/jvm/jre-1.7.0 -> /etc/alternatives/jre_1.7.0

$ ls -la /etc/alternatives/jre_1.7.0
lrwxrwxrwx. 1 root root 30 Aug 28 10:57 /etc/alternatives/jre_1.7.0 -> /usr/lib/jvm/jre-1.7.0-openjdk

$ls -la /usr/lib/jvm/jre-1.7.0-openjdk
lrwxrwxrwx. 1 root root 31 Aug 28 10:57 /usr/lib/jvm/jre-1.7.0-openjdk -> java-1.7.0-openjdk-1.7.0.25/jre

which ultimately leads to a JRE only.


####  While in a standard JBoss installation the variable is set as :

JAVA_HOME=/usr/lib/jvm/java

OR

JAVA_HOME="/opt/java/jdk"

Also if we look at the JBoss supported configuration here [1], only JDKs are certified and supported for running JBoss, not the JREs. Though JBoss runs fine with JRE only, but it is not recommended for few reasons as :

- If user is using any framework which requires compiler API or any class/utility which is present in JDK lib/bin can not be used by the application. For eg :

Apache CXF framework which uses compiler API (JavaCompiler) and need "tools.jar" present in JDK lib. See [2]


The file "standalone.conf" is owned by root user and can not be edited by any other user.

-rwxr-xr-x.  1 root                     5225c48be0b8cd9b32000013  4677 Sep  3 07:14 standalone.conf


I am not sure if we can edit this file in OpenShift Enterprise by SSHing the gear (if yes please let me know), but in OpenShift Online it is impossible to modify the file, to point to JDK instead of JRE. And any application which uses above stated use case will eventually fail.

[1] https://access.redhat.com/site/articles/111663
[2] http://planet.jboss.org/post/jax_ws_tools_and_the_java_compiler_api

--- Additional comment from Dan Mace on 2013-09-06 09:38:04 EDT ---

https://github.com/openshift/origin-server/pull/3567

Cartridge scripts should assume JAVA_HOME is correctly set during install/post-configuration and should never attempt to reassign it.

I audited the jboss* cartridges and found only two instances where JAVA_HOME was being inappropriately overridden via standalone.conf.

--- Additional comment from openshift-github-bot on 2013-09-06 11:13:25 EDT ---

Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/0089fad0e2f8baee182ef7012ccc9f809f4a29f3
Bug 1004927: Don't override JAVA_HOME in standalone.conf

--- Additional comment from Meng Bo on 2013-09-09 02:09:54 EDT ---

Checked on devenv_3758, issue has been fixed.

The JAVA_HOME setting in standalone.xml has been removed.

[jbas1-lxia.dev.rhcloud.com 522d5cd1c7c23dbc1800012e]\> grep "JAVA_HOME" jbossas/standalone/configuration/standalone.xml 
[jbas1-lxia.dev.rhcloud.com 522d5cd1c7c23dbc1800012e]\> 

Move bug to verified.
Comment 1 John Keck 2013-09-17 15:44:43 EDT
We need to get this pulled into a 1.2.x release of OSE
Comment 4 Brenton Leanhardt 2013-09-27 11:23:45 EDT
Upstream commit:

commit 0089fad0e2f8baee182ef7012ccc9f809f4a29f3
Author: Dan Mace <ironcladlou@gmail.com>
Date:   Fri Sep 6 09:36:33 2013 -0400

    Bug 1004927: Don't override JAVA_HOME in standalone.conf
Comment 6 Gaoyun Pei 2013-09-29 02:33:29 EDT
Verify this issue with openshift-origin-cartridge-jbosseap-2.3.11.3-1.git.0.4d0ae9b.el6op.noarch on puddle 1.2/2013-09-27.1 

Create a JbossEAP-6.0 app, check the JAVA_HOME env variables:
[app2-1234.0927-ose.com.cn 5247a94c5946d3132c00005f]\> env|grep JAVA
JAVA_HOME=/etc/alternatives/java_sdk_1.6.0

Check the java app is using:
[app2-1234.0927-ose.com.cn 5247a94c5946d3132c00005f]\> ps -ef |grep java |grep -v grep
1003     12681 12504  0 00:15 ?        00:00:41 /etc/alternatives/java_sdk_1.6.0/bin/java -D[Standalone] -server -XX:+UseCompressedOops -XX:+TieredCompilation -Xmx256m -XX:MaxPermSize=102m -XX:+AggressiveOpts -Dorg.apache.tomcat.util.LOW_MEMORY=true -DOPENSHIFT_APP_UUID=5247a94c5946d3132c00005f -Dorg.jboss.resolver.warning=true -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Djboss.node.name=app2-1234.0927-ose.com.cn -Djgroups.bind_addr=127.1.245.129 -Dorg.apache.coyote.http11.Http11Protocol.COMPRESSION=on -Dorg.jboss.boot.log.file=/var/lib/openshift/5247a94c5946d3132c00005f/jbosseap/standalone/log/boot.log -Dlogging.configuration=file:/var/lib/openshift/5247a94c5946d3132c00005f/jbosseap/standalone/configuration/logging.properties -jar /var/lib/openshift/5247a94c5946d3132c00005f/jbosseap/jboss-modules.jar -mp /var/lib/openshift/5247a94c5946d3132c00005f/app-root/runtime/repo//.openshift/config/modules:/var/lib/openshift/5247a94c5946d3132c00005f/jbosseap/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -Djboss.home.dir=/var/lib/openshift/5247a94c5946d3132c00005f/jbosseap

They are the same, and it's using JDK instead of JRE now.
Comment 9 errata-xmlrpc 2013-10-16 11:39:16 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-1435.html

Note You need to log in before you can comment on or make changes to this bug.