Bug 1004927 - JBoss cartridges are not using env variables to determine JAVA_HOME
JBoss cartridges are not using env variables to determine JAVA_HOME
Product: OpenShift Online
Classification: Red Hat
Component: Containers (Show other bugs)
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Dan Mace
libra bugs
Depends On:
Blocks: 1009152
  Show dependency treegraph
Reported: 2013-09-05 14:44 EDT by Jhon Honce
Modified: 2015-05-14 19:27 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1009152 (view as bug list)
Last Closed: 2013-09-19 12:49:34 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jhon Honce 2013-09-05 14:44:51 EDT
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

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 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-, require the sun jdk.
if [ -e ${OPENSHIFT_REPO_DIR}.openshift/markers/java7 ];

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-

which ultimately leads to a JRE only.

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




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 09:38:04 EDT

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 11:13:25 EDT
Commit pushed to master at https://github.com/openshift/origin-server

Bug 1004927: Don't override JAVA_HOME in standalone.conf
Comment 4 Meng Bo 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.

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