Bug 1004927

Summary: JBoss cartridges are not using env variables to determine JAVA_HOME
Product: OpenShift Online Reporter: Jhon Honce <jhonce>
Component: ContainersAssignee: Dan Mace <dmace>
Status: CLOSED CURRENTRELEASE QA Contact: libra bugs <libra-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.xCC: bmeng, John.Liptak, nmone
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1009152 (view as bug list) Environment:
Last Closed: 2013-09-19 16:49:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1009152    

Description Jhon Honce 2013-09-05 18:44:51 UTC
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:

Comment 1 Nikhil Mone 2013-09-06 10:35:49 UTC
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

Comment 2 Dan Mace 2013-09-06 13:38:04 UTC
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.

Comment 3 openshift-github-bot 2013-09-06 15:13:25 UTC
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

Comment 4 Meng Bo 2013-09-09 06:09:54 UTC
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.