Bug 17193 - java.net.bindException during shutdown in Tomcat 4.1.18
Summary: java.net.bindException during shutdown in Tomcat 4.1.18
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 4
Classification: Unclassified
Component: Connector:Coyote JK 2 (deprecated) (show other bugs)
Version: 4.1.18
Hardware: All other
: P3 normal with 14 votes (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 17702 19098 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-02-19 07:05 UTC by ankur
Modified: 2004-11-16 19:05 UTC (History)
5 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ankur 2003-02-19 07:05:16 UTC
Following error was encountered while shutdown, i m giving complete log message 
from startup to shutdown
 
[INFO] Registry - -Loading registry information
[INFO] Registry - -Creating new Registry instance
[INFO] Registry - -Creating MBeanServer
[INFO] Http11Protocol - -Initializing Coyote HTTP/1.1 on port 8080
Starting service Tomcat-Standalone
Apache Tomcat/4.1.18
[INFO] Http11Protocol - -Starting Coyote HTTP/1.1 on port 8080
[INFO] ChannelSocket - -JK2: ajp13 listening on 0.0.0.0/0.0.0.0:8009
[INFO] JkMain - -Jk running ID=0 time=10/100  config=d:\Tomcat 4.1.18
\conf\jk2.properties
Stopping service Tomcat-Standalone
java.net.BindException: Cannot assign requested address: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:350)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:137)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:124)
        at java.net.Socket.<init>(Socket.java:268)
        at java.net.Socket.<init>(Socket.java:122)
        at org.apache.jk.common.ChannelSocket.destroy(ChannelSocket.java:417)
        at org.apache.jk.server.JkMain.stop(JkMain.java:308)
        at org.apache.jk.server.JkCoyoteHandler.destroy
(JkCoyoteHandler.java:179)
        at org.apache.coyote.tomcat4.CoyoteConnector.stop
(CoyoteConnector.java:1081)
        at org.apache.catalina.core.StandardService.stop
(StandardService.java:546)
        at org.apache.catalina.core.StandardServer.stop
(StandardServer.java:2224)
        at org.apache.catalina.startup.Catalina$CatalinaShutdownHook.run
(Catalina.java:624)
 
what i figured out by looking at the code of  "ChannelSocket.java" was that in 
method "init" of class "ChannelSocket"  the following code
 
        if (getAddress() == null)
                setAddress("0.0.0.0");
 
is setting 'inet' variable to address 0.0.0.0, which is creating problems at 
the time of shutdown when method "destroy" is called and a new socket creation 
is tried which results in the above mentioned "Bind Exception"...
      
      	if (inet == null) {
                s=new Socket("127.0.0.1", port );
        }else{
              s=new Socket(inet, port );
                 // setting soLinger to a small value will help shutdown the
                 // connection quicker
              s.setSoLinger(true, 0);
        }
Comment 1 ankur 2003-02-20 06:42:36 UTC
nobody seems to be interested in resolving this bug!!!
Comment 2 Costin Manolache 2003-03-14 00:15:29 UTC
Fixed in CVS, next release of jk2 will probably have it.
Comment 3 li1yang 2003-04-16 23:18:29 UTC
 Hi, 

      We have the same issue here. If our customer does't 
want to reinstall Tomcat, how should we install the new
fix? Is there a patch for this bug? 
Any information will be apprecicated.


         Thanks,
            -li1yang
Comment 4 Laurent CAPRANI 2003-05-23 20:54:27 UTC
The current stable release (4.1.24) of Tomcat does not fix this bug.
Is there a patch available? How to build it?
Simply replacing tomcat-jk2.jar with the one in Tomcat 5.0.2 (dated May 3rd) 
does not work.
Comment 5 Joe Boon 2003-05-30 14:39:05 UTC
This is still occuring in Tomcat 4.1.24
Bug 19098 seems to be a duplicate of this, but the resolution isn't helpful.
Comment 6 Laurent CAPRANI 2003-07-13 23:44:04 UTC
*** Bug 17702 has been marked as a duplicate of this bug. ***
Comment 7 Laurent CAPRANI 2003-07-13 23:49:57 UTC
*** Bug 19098 has been marked as a duplicate of this bug. ***
Comment 8 Jon Skeet 2003-09-08 10:33:58 UTC
Is there any actual movement on this? I could really do with a fix for it, and
am willing to put some work in myself, but in order to fix the bug I'd have to
know where the source for tomcat-jk.jar itself is, I suspect - and I can't find
that... It's not in the Tomcat 4.1.27 source distribution - where does it come from?
Comment 9 Jon Skeet 2003-09-08 13:51:28 UTC
Right. This doesn't look like it's been fixed in CVS at all, as far as I can see
- Costin, can you remember why you made the comment you did? (The original
comment about the cause of the problem is spot on.)

I'm using Tomcat 4.1.27, and have modified the source locally just to check
whether inet.toString().equals ("0.0.0.0/0.0.0.0") and use 127.0.0.1 if so. That
doesn't feel like a good fix to me, however - I don't like comparing the
contents of .toString with anything else.

Do we know why inet is being set to 0.0.0.0 in the first place? Is there
anything wrong with leaving it as null, but using an inet address of 0.0.0.0 in
init instead? Really, this is a question of whether other classes will assume
that inet is going to have a non-null value. (It's got package protection, so is
available from other classes.)

I don't think I know enough about jk2 to fix this *properly* myself, though I
may well be able to fix it well enough to make do for the installations I'll be
using it with (eg no JMX etc). I certainly need to get it cleared up to *some*
extent before I can ship Tomcat 4.1 with our product.

Does anyone with a bit more knowledge (not saying much :) fancy commenting on
this, or shall I implement my own somewhat hacky solution for my own private
use? (I really don't think I could come up with one I'd be happy enough to
submit as a patch.)
Comment 10 Mark Thomas 2004-05-22 22:21:33 UTC
AFAIKT this was fixed for the 2.0.4 release of jk2. See 
http://cvs.apache.org/viewcvs.cgi/jakarta-tomcat-
connectors/jk/java/org/apache/jk/common/ChannelSocket.java?
r1=1.44&r2=1.45&diff_format=h

There has not been a TC4 release since this date. TC5.0.20 or later will 
include it.