0

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

suitedupgeek
  • 125
  • 1
  • 7

1 Answers1

1

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.

Janne Pikkarainen
  • 31,454
  • 4
  • 56
  • 78
  • Seems ok:[root@server home]# file /etc/init.d/tomcat6 /etc/init.d/tomcat6: Bourne-Again shell script text executable – suitedupgeek Nov 10 '10 at 11:10
  • Double-check with `cat -vT /etc/init.d/tomcat6` -- if you see ^M characters at the end of the lines, then it's in DOS format. I still suspect this due the \r stuff going on in your 'screenshot' :) – Janne Pikkarainen Nov 10 '10 at 11:11
  • Nope, definitely ok. Ran it through dos2unix just to be safe - same issues. – suitedupgeek Nov 10 '10 at 11:23
  • If you manually inspect that file, are there those \r characters all around, then? – Janne Pikkarainen Nov 10 '10 at 11:31
  • Oh! Now I got it. Most likely some of your Tomcat configuration files are in DOS format. Do check those next. :) – Janne Pikkarainen Nov 10 '10 at 11:32
  • Ah. Think I've got it. I read through the actual tomcat6 script, and have narrowed down where the error log is. I'm getting Could not reserve enough space for object heap errors when it's trying to pass the stop command. This is a VM so will look at increasing limits. – suitedupgeek Nov 10 '10 at 11:39
  • But that does not explain all that \r flood you're seeing during start. Those are coming from somewhere. – Janne Pikkarainen Nov 10 '10 at 11:40
  • Yeah, that is weird - all the conf files are checking out ok. I only access this machine from a FC12 install - I guess the other guy might have broken it but I find that hard to believe. – suitedupgeek Nov 10 '10 at 11:43
  • Time for some detective work! See from init script what variable is used in that `chown` part. Then see where that variable is defined. Clearly the user and group are defined somewhere where they are in their own lines and in DOS format... – Janne Pikkarainen Nov 10 '10 at 11:46
  • One great place to mess this kind of things up is under `/path/to/your/tomcat/bin` -- the scripts under there are heavily used during Tomcat startup. – Janne Pikkarainen Nov 10 '10 at 11:48
  • Found it. cd /usr/share - ls drwxr-xr-x 3 root root 4096 Nov 10 10:12 tomcat6 drwxr-xr-x 3 root root 4096 Nov 10 10:10 tomcat6? – suitedupgeek Nov 10 '10 at 11:52
  • Yeah. Try to examine files under `/usr/share/tomcat6/bin`, that might be the place with the rebel DOS files. – Janne Pikkarainen Nov 10 '10 at 11:53
  • Yeah, there's a whole folder which has DOS'd files all over the place. Idiot developer :( – suitedupgeek Nov 10 '10 at 11:54
  • So there's your problem. `dos2unix` all of them and magically see your mysterious problem disappear! I hope. – Janne Pikkarainen Nov 10 '10 at 11:56
  • [root@server tomcat6]# /etc/init.d/tomcat6 restart Stopping tomcat6: [ OK ] Starting tomcat6: [ OK ] – suitedupgeek Nov 10 '10 at 12:00
  • Glad I was able to help. I know your pain of installing/maintaining software provided by others ... – Janne Pikkarainen Nov 10 '10 at 12:01