• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to catch ClientAbortException in Tomcat hosted servlets

 
Hooplehead
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

(hope this is the correct forum...servlets was a contender...would not be surprise if it was moved, but i am pretty sure my question is tomcat specific)

How do I catch org.apache.catalina.connector.ClientAbortException? It is a subclass of IOException, which I am catching, but I'd like to be more specific so I can just log a debug or info entry as ClientAbortException are likely to occur somewhat often in my application.

On my dev platform (Java 5, Tomcat 5.5, Eclipse 3.2) it all works good after including catalina.jar in my project. But when I deploy the project I get dependencies errors, to my surprise.

Any pointers?

tia,

Stu
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looking at the source code, there is nothing magical about ClientAbortException, it just extends IOException and does not add anything special.

You should be able to get at the Throwable cause and the String message with normal Exception methods.
getRootCause()
getMessage()

printStackTrace could be useful too.

Bill
 
Stu Thompson
Hooplehead
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill,

I should have included some code in the original post. It was just getting a bit long as it was. Let me correct that:



See, my ClientAbortException is an expected event. I don't really want to know about it. But any other IOException is noteworthy and should be logged.

To specifically catch the ClientAbortException I brought catalina.jar into my project's classpath. But when I deploy the servelet I get a dependancy issues...the webapp is marked as unavailable because it cannot resolve ClientAbortException It would seem unwise and incorrect to add a copy of catalina.jar to my ./WEB-INF/lib folder.

Stu
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That would indicate that your deployment environment is somehow different from your compilation environment. Exactly what is the error message?

The comments in the ClientAbortException source indicate it was last changed in August 2005. What is your deployment environment?

Bill
 
Stu Thompson
Hooplehead
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yea, the thought crossed my mind. I am pretty keen on development/production consistancy but have double checked and confirmed explicately that both versions are 5.5.17. (April 2006)

The error with ClientAbortExcpetion catch block:



My googles have been fruitless.

Thanks for your time and effort. Appreciated.

Stu
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I'm mystified totally and I am reduced to asking really simple minded questions.
1. If you remove that exception reference can you deploy the servlet?
2. If that code is in your actual servlet class as it appears from that stack trace due to servlet instance construction, what happens if you remove it to a helper class that will only be created on demand?
Bill
 
Stu Thompson
Hooplehead
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

1. If you remove that exception reference can you deploy the servlet?



Yup, it works. That was my first debugging move after seeing the class definition error.

If that code is in your actual servlet class as it appears from that stack trace due to servlet instance construction, what happens if you remove it to a helper class that will only be created on demand?



Interesting idea. After moving all the logic to a seperate ReadAndSpew class and having the actual servelet FileServer class (that extnends HttpServlet) and instances ReadAndSpew on each doGet() method call...it blows up with the same ClientAbortException class definition exception when attempting to create a ReadAndSpew instance.

Perplexed.

Thanks again,

Stu

[ November 27, 2006: Message edited by: Stu Thompson ]
[ November 27, 2006: Message edited by: Stu Thompson ]
 
Stu Thompson
Hooplehead
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BTW, here is the actual 'new' excpetion error log.



Edit: Ho, hum...a friend of mine who I just consulted on this has chastised me for writing tightly coupled container-specific code :roll: which is a good point. I think for now I am going to write some code that inspects ioe.getClass().getName() which will loosen things up a bit.

Not knowing why my dev environment is working and production not will bother me for ages. I might even reinstall the dev environment to re-standardize my development space.

Thanks for your help, though!

Stu

[ November 27, 2006: Message edited by: Stu Thompson ]
[ November 27, 2006: Message edited by: Stu Thompson ]
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have certainly nailed it down with those tests.
I am reduced to suggesting that the Tomcat JVM is finding the package org.apache.catalina.connector
in another, much older Jar file somewhere which does not contain that class.
Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic