Centos – tomcat6 on centos 5.5 not stopping

centostomcat6

Configuring a server for a friend, first time I've dealt with Tomcat and I'm close to tearing what little hair I have left, out 🙂

For his project he needs to use a PHP Java Bridge, I've got the server to the point that Tomcat6 is installed and running, as is the bridge. He can access it via a localhost call like this:

<?php require_once("http://localhost:8080/JavaBridge/java/Java.inc");?> 

This all works fine.

[root@server home]# wget -q http://localhost:8080/JavaBridge/java/Java.inc
[root@server home]# ls | grep Java.inc
Java.inc

Service is running nicely:

[root@server home]# ps ax | grep tomcat
44747 ?        Sl     0:03 /usr/lib/jvm/java/bin/java -classpath :/usr/share/tomcat6/bin/bootstrap.jar:/usr/share/tomcat6/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat6 -Dcatalina.home=/usr/share/tomcat6 -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/cache/tomcat6/temp -Djava.util.logging.config.file=/usr/share/tomcat6/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina.startup.Bootstrap start
[root@server home]# /etc/init.d/tomcat6 status
tomcat6 (pid 44747) is running...

Now, if we ever need to restart – I'm getting this:

[root@server home]# /etc/init.d/tomcat6 restart
Stopping tomcat6:                                          [FAILED]
Starting tomcat6:                                          [  OK  ]

Somewhat perplexing, if I kill the pid and then start I end up with

[root@server tomcat6]# /etc/init.d/tomcat6 start
: command not found6.conf: line 10: 
: command not found6.conf: line 13: 
: command not found6.conf: line 19: 
: command not found6.conf: line 22: 
: command not found6.conf: line 25: 
: command not found6.conf: line 28: 
: command not found6.conf: line 31: 
: command not found6.conf: line 34: 
: command not found6.conf: line 37: 
: command not found6.conf: line 40: 
: command not found6.conf: line 43: 
: command not found6.conf: line 46: 
Starting tomcat6: chown: `tomcat\r:tomcat\r': invalid user
chown: `tomcat\r:tomcat\r': invalid user does not exist, creating
ln: creating symbolic link `/usr/share/tomcat6\r/work' to `/var/cache/tomcat6': No such file or directory
ln: creating symbolic link `/usr/share/tomcat6\r/temp' to `/var/tmp/tomcat6': No such file or directory
chown: `tomcat\r:tomcat\r': invalid user
                                                       [FAILED]

Any ideas?

Much appreciated 🙂

Best Answer

To me this sounds like someone has edited /etc/init.d/tomcat6 script in some Windows text editor and now the script has DOS line feeds instead of Unix line feeds, which confuses the init system.

Use file /etc/init.d/tomcat6 to check if this is true. If it is, use for example dos2unix /etc/init.d/tomcat6 to convert the file to Unix line feeds.