File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Performance and the fly likes Tomcat HttpClient POST problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Tomcat HttpClient POST problem" Watch "Tomcat HttpClient POST problem" New topic

Tomcat HttpClient POST problem

alex ene

Joined: Jun 09, 2009
Posts: 2
Hi all,

I've got a very weird problem...
I am using: Apache Tomcat 5.5, Java 1.5.0, HttpClient (commons-httpclient-3.1.jar).
We have a huge platform that is loaded with the Tomcat Server. But something weird is going on...
Basically when we are trying to send an XML petition via a PostMethod using our platform which creates a
new thread for each job, an connection timeout error occurs, but we are trying to send it by using a simple
thread with a PostMethod, it all works very well.
The two petitions are IDENTICAL - including java code, but it seems that in the case of our platform, the response of the
.executeMethod() is getting very late and with an error.

I wonder which may be the causes for this delay?
More than that, with an older version of our software, everything goes smooth, the code is identical with the one of the
current version, but still there is a difference of how the PostMethod petition is executed. The commons-httpclient.jar
are identical. There are no other jars in the commons of tomcat or in any other classpath folder.

Anybody got any idea about what is going wrong?

Thanks in advance!
Michael Schlegel

Joined: Sep 11, 2009
Posts: 13

I don't know exactly from where comes your problem, but one question:
Do you use MultiThreadedHttpConnectionManager to handle http connections inside HttpClient?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Do I understand correctly that you're saying that single POSTs work OK, but when you flood the Tomcat server with multiple POST threads, it's a problem?

If so, yes it is. Tomcat has a fixed-size thread pool. When more requests come in than there are threads in the pool, the extra requests are going to suffer.

An IDE is no substitute for an Intelligent Developer.
alex ene

Joined: Jun 09, 2009
Posts: 2
The problem was in fact that the application was executing POST-s via a .jar file of some free GIS -type API.
And that POST method was using some native java classes to send the POST-s.
I had to replace the class from the jar, overwriting it with the same class but I had to change the code
that was sending the POST-s with a code that was sending them using the Apache httpclient library.
It seems that the java native way of sending POST-s was working with a delay, but, using the
httpclient it worked perfectly.
I agree. Here's the link:
subject: Tomcat HttpClient POST problem
jQuery in Action, 3rd edition