Bug 1282852 - Tomcat Does not properly parse spaces in JVM parameters/setttings
Tomcat Does not properly parse spaces in JVM parameters/setttings
Product: OpenShift Container Platform
Classification: Red Hat
Component: Image (Show other bugs)
Unspecified Unspecified
low Severity low
: ---
: ---
Assigned To: Vu Dinh
Gaoyun Pei
: Reopened
Depends On: 1282850
  Show dependency treegraph
Reported: 2015-11-17 10:57 EST by Eric Rich
Modified: 2016-08-24 15:44 EDT (History)
11 users (show)

See Also:
Fixed In Version: openshift-origin-cartridge-jbossews-
Doc Type: Bug Fix
Doc Text:
Cause: The tomcat code didn't participate the spaces to be included in environment variables and didn't sanitize the variables before using those. Consequence: The parser split the information in variables incorrectly and caused the JVM command to fail to incomplete or missing parameters. Fix: The new method sh_split is added to tomcat code to sanitize the information in environment variables before parsing them. Result:
Story Points: ---
Clone Of: 1282850
Last Closed: 2016-08-24 15:44:24 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 Eric Rich 2015-11-17 10:57:48 EST
+++ This bug was initially created as a clone of Bug #1282850 +++

Description of problem:

The Tomcat start scripts do not seem to parse or processes JVM values that contain spaces correctly. 

Version-Release number of selected component (if applicable): 2.2 and Online
How reproducible: 100%

Steps to Reproduce:
1. Create a tomcat application 
2. Set an env loaded by the JVM (that contains a space)

$ --> rhc env set JAVA_OPTS_EXT="-Dworking.dir=app-root/data/test dir" -a APP_NAME

3. Restart the application

Actual results:

Tomcat starts with: 

INFO: Destroying ProtocolHandler ["http-bio-"]
Error: Could not find or load main class dir

Expected results:

Tomcat should start without an issue. 

Additional info:

Using various "", '' {quoting structures) or \ {escape characters} do not seem to enable the ability to load environment variables with spaces in them (to the JVM). 
JAVA_OPTS_EXT="-Dworking.dir=app-root/data/test\ dir"

However the following patch can be used to see where the potential issue might be: 

--- /usr/sbin/tomcat7   2015-11-17 10:40:10.659042048 -0500         ### or the tomcat script from the cartridge. 
+++ -   2015-11-17 10:40:29.326768849 -0500
@@ -24,7 +24,7 @@
 CLASSPATH="${CLASSPATH}:$(build-classpath commons-daemon 2>/dev/null)"
 if [ "$1" = "start" ]; then
     -classpath "$CLASSPATH" \
     -Dcatalina.base="$CATALINA_BASE" \
     -Dcatalina.home="$CATALINA_HOME" \

It should be noted that "spaces" in JVM parameters are possible, however they do not seem to be possible in the Tomcat EWS start scripts. 

# java -XX:HeapDumpPath="/tmp/foo bar biz bang.heapdump" -version
openjdk version "1.8.0_65"
OpenJDK Runtime Environment (build 1.8.0_65-b17)
OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode)
Comment 2 Vu Dinh 2016-04-28 09:55:09 EDT

I currently have a PR to improve the tomcat script to handle the white spaces. However, it's still required to have double quote encapsulating the directory which contains the white spaces. So, the correct env var setup command should be:

rhc env set JAVA_OPTS_EXT='-Dworking.dir="app-root/data/test dir"' -a APP_NAME

Comment 3 openshift-github-bot 2016-05-09 12:32:49 EDT
Commit pushed to master at https://github.com/openshift/origin-server

Tomcat does not properly parse spaces in JVM parameters

Tomcat script doesn't correct handle the white places in the parameters passing
via env variable JAVA_OPTS_EXT which causes the JVM fails to parse the parameters
correctly during execution.

The tomcat bash script is modified to handle the white spaces and ensured the space
is not ignored by adding the extra double quotes around the "JAVA_OPTS_EXT".

Bug: 1282852
Link: <https://bugzilla.redhat.com/show_bug.cgi?id=1282852>

Signed-off-by: Vu Dinh <vdinh@redhat.com>
Comment 14 errata-xmlrpc 2016-08-24 15:44:24 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.


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