Bug 33971

Summary: DNS lookup mix of threads
Product: Tomcat 5 Reporter: Susanne <susnet>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Severity: major    
Priority: P2    
Version: 5.0.27   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
URL: http://susnet.se
Attachments: server.xml Tomcat

Description Susanne 2005-03-11 22:29:50 UTC
The problem is that the host names are getting mixed up with each other. It 
seems like a threading problem in Tomcat.

I use resolveHost=true in Tomcat and I get a host but most often not the right 
one for the ip, but for another ip that sends a request at almost the same time.

When I used the same code in Tomcat 5.0.49 this wasn't a problem.
Comment 1 Remy Maucherat 2005-03-11 23:35:14 UTC
Please provide detailed instructions on how to reproduce this.
Comment 2 Susanne 2005-03-12 00:42:21 UTC
Created attachment 14467 [details]
server.xml Tomcat

Using virtual hosts and AJP1.3.
Comment 3 Susanne 2005-03-12 00:42:55 UTC
Created attachment 14468 [details]
Comment 4 Susanne 2005-03-12 00:47:55 UTC
This is what i have in httpd.conf

<VirtualHost *>
ServerName susnet.se
ServerAlias www.susnet.se
ServerAdmin webmaster@susnet.se
DocumentRoot /usr/tomcat-5/webapps/susnet
ErrorLog /usr/tomcat-5/logs/susnet.se-errorlog
CustomLog /usr/tomcat-5/logs/susnet.se-customlog combined
jkMount /* ajp13

In the code for my application i have 

boolean insertOk = stat.insertLogs(id, request.getRemoteAddr(),

 public boolean insertLogs(int counterId, String ip, String hostname,
                         String referer) {

    try {
      PreparedStatement pstmt = connection.prepareStatement(
          "INSERT INTO service.logs VALUES(?, NOW(), ?, ?, ?)");
      synchronized (pstmt) {
        pstmt.setInt(1, counterId);
        pstmt.setString(2, ip);
        pstmt.setString(3, hostname);
        pstmt.setString(4, referer);
    catch (Exception e) {
          "Error i susnet.se/tjanster statistics.java insertLogs.");
          return false;
    return true;

this is executed in a standard Struts executeLogic. There is no problem with 
anything else and it worked fine when I used Tomcat 5.0.49 and JK2.

Tell me if you want some more input!

Comment 5 Susanne 2005-03-12 00:51:47 UTC
It was Tomcat 5.0.27 it worked fine in, not 5.0.49. Sorry.
Comment 6 Susanne 2005-03-12 00:54:40 UTC
Summerized the problem occures with

Tomcat 5.5.7
JK 1.2.8
Apache 2.0.53 (and also 2.0.49)
Comment 7 william.barker 2005-03-12 01:32:33 UTC
It seems that we do have a bug here.

You can fix your system today by including:
  HostnameLookups On
in your httpd.conf.  This is much more efficient anyway if you want host 
names, since then Apache looks it up and tells Tomcat what it is.
Comment 8 william.barker 2005-03-12 04:28:24 UTC
This is fixed now in the CVS, and will appear in 5.5.9.