You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Susan Richards <Ri...@matc.edu> on 2007/08/10 22:28:28 UTC

java.net.BindException: Address already in use

First, I just want to say that I sure appreciate all the help I am getting on this list and I don't deserve to even associate with highly intelligent beings such as yourselves.
 
We shutdown and restart our tomcat 5.5.23 server nightly.  Initially, a maintenance page for system backup gets copied and then it gets bounced with the shutdown.sh and startup.sh scripts.  Since we upgraded last Friday, it's not always starting up.  I see this message in the log:
 
SEVERE: Error initializing endpoint
java.net.BindException: Address already in use (errno:226):80
 
I've checked server.xml and I only have one connector using this port.  Perhaps all the connections are not getting terminated when it shuts down?  How do I fix this problem?  How do I figure out what is the cause?

Re: java.net.BindException: Address already in use

Posted by Susan Richards <Ri...@matc.edu>.
>Just out of curiosity, why do you bounce Tomcat every night?
We backup our database that the web application interfaces with.  We stop our listener after we bounce it and put a maintenance page out.  Our application gives a 'System Error Detected' to the user if we don't do things in the right order.  I suppose I could just copy the maintenance page and not bounce it....
 
I did have a delay, but then we switched scripts for a different problem.  I will try going back to the old script now because that problem is resolved.  I hope.  Thanks.

>>> Christopher Schultz <ch...@christopherschultz.net> 8/10/2007 3:41 PM >>>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Susan,

Susan Richards wrote:
> First, I just want to say that I sure appreciate all the help I am
> getting on this list and I don't deserve to even associate with
> highly intelligent beings such as yourselves.

Seriously, don't say that. :(

> We shutdown and restart our tomcat 5.5.23 server nightly.  Initially,
> a maintenance page for system backup gets copied and then it gets
> bounced with the shutdown.sh and startup.sh scripts.  Since we
> upgraded last Friday, it's not always starting up.  I see this
> message in the log:
> 
> SEVERE: Error initializing endpoint java.net.BindException: Address
> already in use (errno:226):80

Don't forget that shutdown.sh only sends a shutdown notification to
Tomcat -- it doesn't wait for the shutdown to complete before the script
ends. So, you can't just do "shutdown.sh" followed by "startup.sh" and
expect a clean server bounce.

The quick fix is to introduce some delay between the shutdown and
startup. The problem is, it might not take a predictable amount of time
to shutdown, so you can't just guess at 5 seconds and leave it at that.

The best thing to do would be to watch catalina.out for the "shutdown"
message that Tomcat emits as it goes down, and /then/ call startup.sh.
Honestly, if you're already comfortable bouncing Tomcat every night, you
can probably just introduce an arbitrary delay between invoking scripts
and be fine.

Just out of curiosity, why do you bounce Tomcat every night?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org ( http://enigmail.mozdev.org/ )

iD8DBQFGvM1+9CaO5/Lv0PARAkNmAJ41+SQAwk3qhjVWGUn1ePWWnRhV4wCcDsbT
ZA3mjT3gTNF+DhDJPyjm4aM=
=7tQ6
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org 
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org 
For additional commands, e-mail: users-help@tomcat.apache.org 


Re: java.net.BindException: Address already in use

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Susan,

Susan Richards wrote:
> First, I just want to say that I sure appreciate all the help I am
> getting on this list and I don't deserve to even associate with
> highly intelligent beings such as yourselves.

Seriously, don't say that. :(

> We shutdown and restart our tomcat 5.5.23 server nightly.  Initially,
> a maintenance page for system backup gets copied and then it gets
> bounced with the shutdown.sh and startup.sh scripts.  Since we
> upgraded last Friday, it's not always starting up.  I see this
> message in the log:
> 
> SEVERE: Error initializing endpoint java.net.BindException: Address
> already in use (errno:226):80

Don't forget that shutdown.sh only sends a shutdown notification to
Tomcat -- it doesn't wait for the shutdown to complete before the script
ends. So, you can't just do "shutdown.sh" followed by "startup.sh" and
expect a clean server bounce.

The quick fix is to introduce some delay between the shutdown and
startup. The problem is, it might not take a predictable amount of time
to shutdown, so you can't just guess at 5 seconds and leave it at that.

The best thing to do would be to watch catalina.out for the "shutdown"
message that Tomcat emits as it goes down, and /then/ call startup.sh.
Honestly, if you're already comfortable bouncing Tomcat every night, you
can probably just introduce an arbitrary delay between invoking scripts
and be fine.

Just out of curiosity, why do you bounce Tomcat every night?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGvM1+9CaO5/Lv0PARAkNmAJ41+SQAwk3qhjVWGUn1ePWWnRhV4wCcDsbT
ZA3mjT3gTNF+DhDJPyjm4aM=
=7tQ6
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: java.net.BindException: Address already in use

Posted by David Smith <dn...@cornell.edu>.
Most linux systems (probably *nix in general) store the pid in a file 
named after the service  in /var/run.  Your restart script could pick up 
that pid and then loop through checking for it's existance about once a 
second until it's gone before continuing with a new startup.  That at 
least is dynamic enough to accommodate long and short shutdown times.  
Keep track of the wait and if it takes too long, log an error.

--David

Manivannan Palanichamy wrote:
> On 8/11/07, Susan Richards <Ri...@matc.edu> wrote:
>   
>> First, I just want to say that I sure appreciate all the help I am getting
>> on this list and I don't deserve to even associate with highly intelligent
>> beings such as yourselves.
>>
>> We shutdown and restart our tomcat 5.5.23 server nightly.  Initially, a
>> maintenance page for system backup gets copied and then it gets bounced with
>> the shutdown.sh and startup.sh scripts.  Since we upgraded last Friday,
>> it's not always starting up.  I see this message in the log:
>>
>> SEVERE: Error initializing endpoint
>> java.net.BindException: Address already in use (errno:226):80
>>
>> I've checked server.xml and I only have one connector using this
>> port.  Perhaps all the connections are not getting terminated when it shuts
>> down?  How do I fix this problem?  How do I figure out what is the cause?
>>
>>     
>
> Sometimes, I too faced this prob. I did a work around. Just grep for the
> tomcat process id. some thing like,
> ps -ax | grep 'endorsed'  //an ugly grep to fetch tomcat process
> as you have got the process id now, kill the tomcat as,
> kill -9 [pid]
>
> Now start the tomcat.
> [also, make sure, you are not running a webserver already on port 80. if you
> are running any oracle server, probably it might be starting a apache
> webserver on 80, pl check]
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: java.net.BindException: Address already in use

Posted by Manivannan Palanichamy <ma...@gmail.com>.
On 8/11/07, Susan Richards <Ri...@matc.edu> wrote:
>
> First, I just want to say that I sure appreciate all the help I am getting
> on this list and I don't deserve to even associate with highly intelligent
> beings such as yourselves.
>
> We shutdown and restart our tomcat 5.5.23 server nightly.  Initially, a
> maintenance page for system backup gets copied and then it gets bounced with
> the shutdown.sh and startup.sh scripts.  Since we upgraded last Friday,
> it's not always starting up.  I see this message in the log:
>
> SEVERE: Error initializing endpoint
> java.net.BindException: Address already in use (errno:226):80
>
> I've checked server.xml and I only have one connector using this
> port.  Perhaps all the connections are not getting terminated when it shuts
> down?  How do I fix this problem?  How do I figure out what is the cause?
>

Sometimes, I too faced this prob. I did a work around. Just grep for the
tomcat process id. some thing like,
ps -ax | grep 'endorsed'  //an ugly grep to fetch tomcat process
as you have got the process id now, kill the tomcat as,
kill -9 [pid]

Now start the tomcat.
[also, make sure, you are not running a webserver already on port 80. if you
are running any oracle server, probably it might be starting a apache
webserver on 80, pl check]
-- 
Manivannan.Palanichamy (@) Oracle.com
http://mani.gw.googlepages.com/index.html