Bug 1282852 - Tomcat Does not properly parse spaces in JVM parameters/setttings
Summary: Tomcat Does not properly parse spaces in JVM parameters/setttings
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Image
Version: 2.2.0
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
: ---
Assignee: Vu Dinh
QA Contact: Gaoyun Pei
Depends On: 1282850
TreeView+ depends on / blocked
Reported: 2015-11-17 15:57 UTC by Eric Rich
Modified: 2019-09-12 09:19 UTC (History)
11 users (show)

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:
Clone Of: 1282850
Last Closed: 2016-08-24 19:44:24 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:1773 normal SHIPPED_LIVE Important: Red Hat OpenShift Enterprise 2.2.10 security, bug fix, and enhancement update 2016-08-24 23:41:18 UTC

Description Eric Rich 2015-11-17 15:57:48 UTC
+++ 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 13:55:09 UTC

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 16:32:49 UTC
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 19:44:24 UTC
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.