views:

483

answers:

4

I'm having trouble getting tomcat to start

I followed these instructions to get tomcat / apache2 running:

http://www.mogilowski.net/?p=121

...but tomcat fails to start on reboot. Here's the message from the log:

Nov 30, 2009 6:59:53 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 13009 ms
Nov 30, 2009 6:59:53 PM org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[8005]:
java.net.BindException: Address already in use
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
        at java.net.ServerSocket.bind(ServerSocket.java:319)
        at java.net.ServerSocket.<init>(ServerSocket.java:185)
        at org.apache.catalina.core.StandardServer.await(StandardServer.java:373)
        at org.apache.catalina.startup.Catalina.await(Catalina.java:647)        at org.apache.catalina.startup.Catalina.start(Catalina.java:607)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:2
5)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Nov 30, 2009 6:59:53 PM org.apache.coyote.http11.Http11Pro

It says that [8005] is already in use, however a netstat -napa shows nobody has that port.

I can start it manually by running

/etc/init.d/tomcat stop

and then doing a netstat and killing the process that has port 8080 and doing an

/etc/init.d/tomcat start

tried removing the init.d tomcat script, booting the system, and running a netstat -napa to see if anyone has port 8080, or 8000 through 8009 and nobody does. A "telnet" to this port upon a fresh boot gives me

root@domU-12-31-39-00-A1-C4:/usr/local/tomcat/logs# telnet localhost 8005
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused

..but if I try to start up tomcat, either by hand or via init.d script, it will fail the first time, complaining about the "Address already in use"

any ideas?

A: 

It says that [8005] is already in use, however a netstat -napa shows nobody has that port.

well nobody might be running another web server...

but seriously, what is the contents of the init script you use to start tomcat, and what does netcat -tnlpe | grep $yourport say?

just somebody
A: 

Is it possible you have another instance of Tomcat running? For example, if there's a Tomcat startup script running without your knowledge when the system boots, it would make sense that you're getting this error.

spork
I'm thinking that something, somewhere, is trying to start Tomcat twice. But then wouldn't Tomcat be running, and just the second instance attempt will fail? In my case--after booting the machine clean--Tomcat won't start up. There's nothing listening on 8080, etc.
ראובן
A: 

You can get this kind of error from tomcat if you either try to restart before a previous shutdown has completed or after a shutdown that's not clean - e.g, if you have a webapp that starts some manually managed threads and leave them hanging, and then call the tomcat shutdown script, the tomcat service will stop responding on the port but the process will not die.

it looks like the apache script on that page calls tomcat restart (i.e. shutdown, startup) and you then have the tomcat service configured as well, so if the apache script loads first tomcat start will be called with tomcat already running and if tomcat is first you'll call shutdown/startup with tomcat already running.

Steve B.
Well, it never starts up properly when then machine reboots, so I don't think it's after a shutdown that's not clean.Is it that both the Apache start and the Tomcat start are trying to start Tomcat?
ראובן
Do you have both Apache AND Tomcat installed?
spork
A: 

In addition to others' explanations: ps -ux will show you the tomcat (do it with the user that started it), and kill pid the process (pid is the process id)

Bozho