Bug 899458 - JAVA_OPTS in /etc/tomcat6/tomcat6.conf get added twice
Summary: JAVA_OPTS in /etc/tomcat6/tomcat6.conf get added twice
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: JBoss Enterprise Web Server 2
Classification: JBoss
Component: unspecified
Version: 2.0.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: 2.0.0
Assignee: Permaine Cheung
QA Contact:
URL: http://jira.jboss.org/jira/browse/JBE...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-07-19 02:12 UTC by James Livingston
Modified: 2016-02-22 00:56 UTC (History)
3 users (show)

Fixed In Version:
Clone Of: JBEWS-249
Environment:
RHEL 5, probably other RHEL versions
Last Closed: 2011-09-22 20:36:40 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker JBEWS-249 0 Major Closed JAVA_OPTS in /etc/tomcat6/tomcat6.conf get added twice 2019-03-05 12:33:38 UTC

Description James Livingston 2011-07-19 02:12:40 UTC
++ This bug is a clone of bug 899457 ++

Steps to Reproduce: 1) Edit /etc/tomcat6/tomcat6.conf and add:
  JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
2) run "service tomcat6 start"
3) Look at /var/log/tomcat6/catalina.out, and see that it has failed to start because the debug options have been specified twice

This can be seen more clearly by editing /usr/sbin/tomcat6 to print out the command it is about to execute.
Workaround Description: Remove the following lines from /usr/sbin/tomcat6
{code}
# Get the tomcat config (use this for environment specific settings)
if [ -z "${TOMCAT_CFG}" ]; then
  TOMCAT_CFG="/etc/tomcat6/tomcat6.conf"
fi

if [ -r "$TOMCAT_CFG" ]; then
  . $TOMCAT_CFG
fi
{code}
project_key: JBEWS

JVM options can be added to JAVA_OPTS in /etc/sysconfig/tomcat6 or /etc/tomcat6/tomcat6.conf (the former per service the latter global). When JAVA_OPTS are added to /etc/tomcat6/tomcat6.conf, they get appended to the command line twice, which can cause problems if specifying the option twice does not have the same effect as specifying it once.

Comment 1 James Livingston 2011-07-19 02:33:01 UTC
Adding JAVA_OPTS in /etc/sysconfig/tomcat6 works correctly, adding it once

Comment 2 James Livingston 2011-07-19 05:30:29 UTC
This is because the following fragment is in both /etc/init.d/tomcat6 and /usr/sbin/tomcat6, so it is executed once by the service wrapper, which then calls the latter script and that runs the configuration file again.

TOMCAT_CFG="/etc/tomcat6/tomcat6.conf"
if [ -r "$TOMCAT_CFG" ]; then
    . $TOMCAT_CFG
fi


A simple fix would be to drop that section from /etc/init.d/tomcat6. However that means that the global configuration there overrides the per-service configuration in /etc/sysconfig/${NAME}, which is almost certainly the wrong way around. If it was dropped from /usr/sbin/tomcat6, then it would mean the no configuration file is read if someone starts tomcat6 outside the service wrapper.

Comment 3 Permaine Cheung 2011-07-19 13:09:18 UTC
Assigning to Dave.

Comment 4 David Knox 2011-07-19 15:13:57 UTC
This will be fixed as recent cves are applied to the tomcat6 builds over the week of 7/18.

Comment 5 David Knox 2011-09-07 20:16:05 UTC
The problem occurs because /usr/sbin/tomcat6 redundantly sources tomcat6.conf. The diffs below show the solution being tested.

{code:title=/usr/sbin/tomcat6}
RCS file: /cvs/dist/rpms/tomcat6/RHEL-4-EP-5/tomcat6-6.0.wrapper,v
retrieving revision 1.4
diff -r1.4 tomcat6-6.0.wrapper
10,22d9
< LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"
< 
< # Get the tomcat config (use this for environment specific settings)
< if [ -z "${TOMCAT_CFG}" ]; then
<   TOMCAT_CFG="/etc/tomcat6/tomcat6.conf"
< fi
< 
< if [ -r "$TOMCAT_CFG" ]; then
<   . $TOMCAT_CFG
< fi
< 
< JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
< 
{code}
{code:title=tomcat6.conf}
RCS file: /cvs/dist/rpms/tomcat6/RHEL-4-EP-5/tomcat6-6.0.conf,v
retrieving revision 1.4
diff -r1.4 tomcat6-6.0.conf
30a31,34
> LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"
> 
> JAVA_OPTS="${JAVA_OPTS} -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
> 

{code}

Comment 6 David Knox 2011-09-07 20:47:02 UTC
Additional consideration of cases when sbin/tomcat6 is used directly, here is new diff for sbin/tomcat6. The caller must define $NAME at least. 

RCS file: /cvs/dist/rpms/tomcat6/RHEL-4-EP-5/tomcat6-6.0.wrapper,v
retrieving revision 1.4
diff -r1.4 tomcat6-6.0.wrapper
10,18c10,23
< LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"
< 
< # Get the tomcat config (use this for environment specific settings)
< if [ -z "${TOMCAT_CFG}" ]; then
<   TOMCAT_CFG="/etc/tomcat6/tomcat6.conf"
< fi
< 
< if [ -r "$TOMCAT_CFG" ]; then
<   . $TOMCAT_CFG
---
> # The wrapper can't be used by itself. The NAME variable must be set by
> # the caller. The first argument in the command line must be one of
> # "start, stop, start-security, or version" 
> 
> if [ "$2" == "stand-alone" ]; then
> 	if [ -z "${TOMCAT_CFG}" ]; then
> 		TOMCAT_CFG="/etc/tomcat6/tomcat6.conf"
> 	fi
> 	if [ -r "${TOMCAT_CFG}" ]; then
> 		. ${TOMCAT_CFG}
> 	fi
> 	if [ -r "/etc/sysconfig/${NAME}" ]; then
> 		. /etc/sysconfig/${NAME}
> 	fi

21,22d25
< JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
< 
{code}


Comment 7 David Knox 2011-09-07 22:52:58 UTC
Sorry about the spam. After testing the changes, they became increasingly kludgey. The tomcat wrapper (sbin/tomcat6) was not intended to be called alone, and shouldn't source the config files. Instructions for creating additional service instances are in /etc/sysconfig/tomcat6. The block that read tomcat6.conf in sbin/tomcat6 will be removed completely. 

Comment 8 David Knox 2011-09-08 22:56:37 UTC
fixed in tomcat6-6.0.32-18_patch_04.ep5.el4

Comment 9 David Knox 2011-09-08 22:56:37 UTC
Workaround Description: Added: Remove the following lines from /usr/sbin/tomcat6
{code}
# Get the tomcat config (use this for environment specific settings)
if [ -z "${TOMCAT_CFG}" ]; then
  TOMCAT_CFG="/etc/tomcat6/tomcat6.conf"
fi

if [ -r "$TOMCAT_CFG" ]; then
  . $TOMCAT_CFG
fi
{code}


Comment 10 David Knox 2011-09-22 20:36:40 UTC
Release Notes Text: Added: /usr/sbin/tomcat6 no longer sources tomcat6.conf


Comment 11 Jiri Skrabal 2012-11-13 16:26:55 UTC
Release Notes Text: Removed: /usr/sbin/tomcat6 no longer sources tomcat6.conf 
Docs QE Status: Removed: NEW 



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