Bug 1282850

Summary: Tomcat Does not properly parse spaces in JVM parameters/setttings
Product: [JBoss] JBoss Enterprise Web Server 2 Reporter: Eric Rich <erich>
Component: tomcat7Assignee: Coty Sutherland <csutherl>
Status: CLOSED DEFERRED QA Contact: Jan Stefl <jstefl>
Severity: high Docs Contact:
Priority: unspecified    
Version: 2.1.0CC: aogburn, erich, fgoldefu, jdoyle, pslavice, rmarwaha, rsvoboda
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1282852 (view as bug list) Environment:
Last Closed: 2017-08-09 16:23:20 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: 1282852    

Description Eric Rich 2015-11-17 15:55:30 UTC
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): 
    EWS 2: tomcat7-7.0.54-19_patch_04.ep6.el6.noarch

How reproducible: 100%

Steps to Reproduce:
1. Install Tomcat7
2. Set an env loaded by the JVM (that contains a space) in /etc/sysconfig/tomcat7
    JAVA_OPTS="-XX:HeapDumpPath='/tmp/foo bar biz bang.heapdump' -version"
3. Restart the application

Actual results:

Tomcat starts with: 

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

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). 

However the following patch can be used to see where the potental 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
-  ${JAVACMD} $JAVA_OPTS $LOGGING_CONFIG $CATALINA_OPTS \
+  ${JAVACMD} "$JAVA_OPTS" $LOGGING_CONFIG $CATALINA_OPTS \
     -classpath "$CLASSPATH" \
     -Dcatalina.base="$CATALINA_BASE" \
     -Dcatalina.home="$CATALINA_HOME" \

It should be noted that "spaces" in JVM paramiters 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 1 Michal Karm Babacek 2016-03-31 17:44:24 UTC
Pending triage...