Jira fails to start if any newlines present in CATALINA_OPTS and/or JAVA_OPTS
問題
Jira fails to start if a newline is used in CATALINA_OPTS and/or JAVA_OPTS. It happens in Jira 8.9 which has been shipped with Tomcat 8.5.50.
Please see: - JRASERVER-70487Getting issue details... STATUS
A setting like below will cause Jira to fail to start:
JVM_SUPPORT_RECOMMENDED_ARGS="
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/data/heapdumps/
...
..."
診断
環境
Jira 8.9 with Tomcat 8.5.50
Diagnostic Steps
Check the customizations in setenv.sh or setenv.bat file done by setting parameters in JVM_SUPPORT_RECOMMENDED_ARGS, JVM_GC_ARGS, or other variables.
原因
Expansion of JAVA_OPTS in catalina.sh containing '*' stops startup on the Linux server. This problem is filed under https://bz.apache.org/bugzilla/show_bug.cgi?id=63815 and it's fixed in Tomcat 8.5.48. This bug does not allow newlines in CATALINA_OPTS and/or JAVA_OPTS.
Part of the fix is to stop the expansion by simply put the use of JAVA_OPTS in double-quotes. i.e. "$JAVA_OPTS". You can see the details in catalina.sh below:
# CATALINA_OPTS and/or JAVA_OPTS require quoting. See:
exec "$_RUNJDB" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
exec "$_RUNJDB" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
eval exec "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER "$JAVA_OPTS" "$CATALINA_OPTS" \
eval exec "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER "$JAVA_OPTS" "$CATALINA_OPTS" \
eval $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER "$JAVA_OPTS" "$CATALINA_OPTS" \
eval $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER "$JAVA_OPTS" "$CATALINA_OPTS" \
eval "\"$_RUNJAVA\"" $LOGGING_MANAGER "$JAVA_OPTS" \
eval "\"$_RUNJAVA\"" $LOGGING_MANAGER "$JAVA_OPTS" \
You can find more details in Tomcat 8.5 Change Log: https://tomcat.apache.org/tomcat-8.5-doc/changelog.html
ソリューション
Remove newlines and set your customizations in one line:
JVM_SUPPORT_RECOMMENDED_ARGS="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/heapdumps/......"