After emerging Tomcat, the init.d script didn't start the server. There seem to be two errors: 1. start-stop-daemon can't start the catalina.sh script properly. 2. The config file for log4j is not specified in /etc/conf.d/tomcat, thus leading to the unlimited output of: log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax). log4j:WARN Please initialize the log4j system properly. Reproducible: Always Steps to Reproduce: 1. emerge tomcat 2. set CATALINA_OPTS="-Dlog4j.configuration=file:/etc/log4j.properties" in /etc/conf.d/tomcat-5 3. /etc/init.d/tomcat-5 start Actual Results: Tomcat did'n start, the init.d stript did not terminate, http://127.0.0.1:8080 was not available. Expected Results: Tomcat should produce a fine page at http://127.0.0.1:8080 I can get round of this trouble by setting the log4j config in /etc/conf.d/tomcat-5 (a hint after emergin Tomcat to do this would have been realy very nice) and patching the /etc/init.d/tomcat-5 script. I'll attach all the modified files as well as a complete log file of my hacking. Thanks for the attention!
Created attachment 66982 [details] Log of the installation/start trials
Created attachment 66983 [details, diff] When I apply this patch to the init script, it works pretty fine
Created attachment 66984 [details] I neet to set the log4j config in /etc/conf.d/tomcat-5
This is very strange. I had to use your fix on tomcat-5.0.27-r6 and tomcat-5.0.28-r4 on my centrino notebook in order to get it to work, yet I didn't have a single problem on my Athlon-XP box when I tried tomcat-5.0.27-r6.
Created attachment 68315 [details, diff] diff of /etc/init.d/tomcat-5 to use /sbin/start-stop-daemon OK, using a lot of strace, equery and grep, I think I solved this mystery. The bad boy is /lib/rcscripts/sh/rc-daemon.sh. There start-stop-daemon is redefined as a shell function, and does some additional work. Especially it checks if the daemon is really started (using some pid file, which is not the tomcat way as far as I know), and calls stop if this is not the case. I changed my /etc/init.d/tomcat-5 to explicitly use /sbin/start-stop-daemon. This allows me to make use of the chuid feature which was a problem with attachment #66983 [details, diff] from comment #2.
*** Bug 88002 has been marked as a duplicate of this bug. ***
I commited tomcat-5.0.28-r5.ebuild to portage. That revision is masked untill people report here. In that revision (and also -r4) proper configuration is added to /etc/conf.d/tomcat-5 and /etc/init.d/tomcat-5 as changed. Revision 5 gains a /etc/tomcat-5/log4j.properties so that no errors are sent to the logs about not finding the file.
I unmasked and tested the -r5 ebuild - and it won't work for me. Seems like it has been forgotten to install the included log4j.properties. therion aaron # /etc/init.d/tomcat-5 start * Caching service dependencies ... [ ok ] * Starting Tomcat ... Using CATALINA_BASE: /var/lib/tomcat-5/default Using CATALINA_HOME: /usr/share/tomcat-5 Using CATALINA_TMPDIR: /var/tmp/tomcat-5/default Using JAVA_HOME: /opt/sun-jdk-1.5.0.04 log4j:ERROR Could not read configuration file from URL [file:/etc/tomcat-5/log4j.properties]. java.io.FileNotFoundException: /etc/tomcat-5/log4j.properties (No such file or directory) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:106) at java.io.FileInputStream.<init>(FileInputStream.java:66)
also I've noted the following line during the build: >>> Install tomcat-5.0.28-r5 into /var/tmp/portage/tomcat-5.0.28-r5/image/ category www-servers cp: target `/var/tmp/portage/tomcat-5.0.28-r5/image//etc/tomcat-5/' is not a directory: No such file or directory man:
Created attachment 68582 [details, diff] fix for the 5.0.28-r5 ebuild making it install the log4j properties seems better to copy the file AFTER the folder has been created dodir. also if we have ${TOMCAT_NAME} we should use it when copying, too
oh no - after my patch the file permissions are messed up. therion tomcat # /etc/init.d/tomcat-5 start * Caching service dependencies ... [ ok ] * Starting Tomcat ... Using CATALINA_BASE: /var/lib/tomcat-5/default Using CATALINA_HOME: /usr/share/tomcat-5 Using CATALINA_TMPDIR: /var/tmp/tomcat-5/default Using JAVA_HOME: /opt/sun-jdk-1.5.0.04 log4j:ERROR Could not read configuration file from URL [file:/etc/tomcat-5/log4j.properties]. java.io.FileNotFoundException: /etc/tomcat-5/log4j.properties (Permission denied) at java.io.FileInputStream.open(Native Method) ...but at least the file now exists and someone smarter than me might finally fix the ebuild
Created attachment 68601 [details, diff] fix for 5.0.28-r5 The privious probably had a typo in the ${TOMACAT_NAME} :) I changed that, the location and fixed the file to be owned by the tomcat user.
Ok, I tested the latest version of the ebuild and things improve - but still aren't perfect. The problems with log4j are gone by now, but the init.d script seems to cause some final problems. When I try to start up tomcat via tomcat-5 init.d script it hangs forever - if I directly use catalina.sh start tomcat starts up just fine. Adding a --background to the start-stop-daemon calls in the tomcat-5 init.d script solved this last problem for me - now I can finally use my tomcat again. Thx for all your efforts and hope that this final fix will solve the problems for everyone else, too.
Added --background to the installed init script. Please reopen if the problem still exists.
the --background isn't only needed on start, but also on stop (or else it hangs on shutdown)
*** Bug 106788 has been marked as a duplicate of this bug. ***
Created attachment 68951 [details] ${FILESDIR}/${PV}/tomcat.init the infos you gave worked perfectly for me too. just attached the new init-script for help
all the 5.0.28 revisions now have --background in stop too.