Two Laptop Bag*
The moose likes Struts and the fly likes Catching all exceptions, thread safety issues, and safely closing a user session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Catching all exceptions, thread safety issues, and safely closing a user session" Watch "Catching all exceptions, thread safety issues, and safely closing a user session" New topic
Author

Catching all exceptions, thread safety issues, and safely closing a user session

Rama Krishna
Ranch Hand

Joined: Oct 16, 2007
Posts: 110
We are currently using Tomcat web server for deploying our application. Most of the modules have a couple of huge reports (take about 30-60 minutes, because of hibernate) running in the background.

Whenever the user initiates the report method by clicking a button and then he accidentally clicks any other button to begin any other method, the tomcat server gets stuck and sometimes returns "Thread Safety Error" message.

1. How do we stop a running (a particular session) method in Tomcat by just a user click and 2. what is the best way to stop displaying or catching any kind of exceptions/errors from being displayed in the users display page? We even have many problems with a particular session not closing properly or at all, 3. safe way to close a hibernate session. Any comments or suggestions on these issues are appreciated.

Thanks
Rama

Thread Subject: Catching all exceptions, thread safety issues, and safely closing a user session
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8866
    
    8

It looks like you already have a discussion going on related to this topic.
Frankly, I think you've made a poor choice of architecture (Tomcat) for your requirements (reports churning through huge amounts of data).
Tomcat is a servlet container. It is not designed to support long-running processes. As you've discovered, is way to easy for your users to violate the HTTP protocol by clicking on another link.
I'd be inclined to move the report functionality off into another application and have a light web application that submits report requests to that app. The report app can send users the reports via email or upload the report somewhere that Tomcat can access and include a URL to the report in the email.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Rama Krishna
Ranch Hand

Joined: Oct 16, 2007
Posts: 110
Joe,

I am still working on tuning our hibernate queries and have already been working on that issue. This is a totally different issue here.

"It looks like you already have a discussion going on related to this topic. Frankly, I think you've made a poor choice of architecture (Tomcat) for your requirements (reports churning through huge amounts of data).
"


Any suggestions on free to use servers for displaying or processing huge reports or database data? Anyways, we do not have much of a choice as we cannot afford and so lets assume that Tomcat is the server.

I'd be inclined to move the report functionality off into another application and have a light web application that submits report requests to that app. The report app can send users the reports via email or upload the report somewhere that Tomcat can access and include a URL to the report in the email."


We already implemented the email and FTP options, but I am sure that there are ways to stop this from happening. Anyways, any of the following issues were related to my previous post:

1. How do we stop a running (a particular session) method in Tomcat by just a user click and 2. what is the best way to stop displaying or catching any kind of exceptions/errors from being displayed in the users display page? We even have many problems with a particular session not closing properly or at all, 3. safe way to close a hibernate session, we had to comment out the session.close() or session.flush() in our method that returns the current session or that creates a new session for use.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8866
    
    8

Originally posted by Rama Krishna:

Any suggestions on free to use servers for displaying or processing huge reports or database data? Anyways, we do not have much of a choice as we cannot afford and so lets assume that Tomcat is the server.

Tomcat can handle the complex front end stuff (multiple simultaneous users, authentication). All you need is something to run reports. I've got many examples that are simple daemon processes, all of 200 lines of code, that read requests off a JMS queue and process them.

Originally posted by Rama Krishna:

1. How do we stop a running (a particular session) method in Tomcat by just a user click

You can't. HTTP is strictly request-response. There is no facility provided to interrupt a request once it is initiated.
Originally posted by Rama Krishna:

2. what is the best way to stop displaying or catching any kind of exceptions/errors from being displayed in the users display page?

You can isolate them with a catch-all try-catch block, but it is still good design to let the user know that something failed.
Originally posted by Rama Krishna:

3. safe way to close a hibernate session, we had to comment out the session.close() or session.flush() in our method that returns the current session or that creates a new session for use.

I am far from a hibernate expert, so you'd be best to ask this in the Hibernate forum. I've been using an interceptor like the example on page 54-55 of Ted Husted's Struts 2 from Square One and it works fine for my purposes.
Rama Krishna
Ranch Hand

Joined: Oct 16, 2007
Posts: 110
Tomcat can handle the complex front end stuff (multiple simultaneous users, authentication). All you need is something to run reports. I've got many examples that are simple daemon processes, all of 200 lines of code, that read requests off a JMS queue and process them.


I know the basics of JMS but I am not sure how I can put any of the user's request and put in a queue and then process based on the requests.. Actually, I could not understand it at all..


I am far from a hibernate expert, so you'd be best to ask this in the Hibernate forum. I've been using an interceptor like the example on page 54-55 of Ted Husted's Struts 2 from Square One and it works fine for my purposes.


I was unable to download the interceptor or able to find an example as I could not get access to Ted Husted's Struts 2 book. Any suggestions where I can get I can access it easily?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8866
    
    8

Originally posted by Rama Krishna:
I was unable to download the interceptor or able to find an example as I could not get access to Ted Husted's Struts 2 book. Any suggestions where I can get I can access it easily?


Go to the site I linked to above and click on the link that says "Working Draft (PDF)".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Catching all exceptions, thread safety issues, and safely closing a user session