• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tomcat exception  RSS feed

 
Divyajot Ahluwalia
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
im using tomcat on top of apache.
the server keeps on throwing a servlet exception every few hrs and all servlets and jsp files stop working...
I am using a mysql db with a connection broker from javasoft.
any suggestions what could be the problem
thanks,
dj
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be able to get some useful information from the nature of the servlet exception. Try to print the stack trace to a file.
You have defined an error page for all of your JSP, I trust.
A typical problem with database applications occurs if you don't close the various database objects - the db eventually runs out of connections or other resources.
Bill
 
Divyajot Ahluwalia
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

thanks bill,
In the case of a servlet, how do i catch a servlet exception?
What are the database objects that need to be closed. in my application i do the following
1) in the connection broker refresh the connections every minute
2) i close all statements and prepared statements
3) free connections from the connection broker object.
what else should i do? i do not close connection objects becoz that currupts the pool the pool of objects in the broker.
In the servlet i start another object which is a thread(runnable). the new thread executes all the database operations and finally closes the statements and frees the connection.
Id this a problem?
thanks
dj
 
Vikas Aggarwal
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could have really helped you if you could let me know the exact servlet exception. For catching that keep whole of your business logic code in try catch block. It will show you the excat error event if it is related to the database.

Originally posted by Divyajot Ahluwalia:

thanks bill,
In the case of a servlet, how do i catch a servlet exception?
What are the database objects that need to be closed. in my application i do the following
1) in the connection broker refresh the connections every minute
2) i close all statements and prepared statements
3) free connections from the connection broker object.
what else should i do? i do not close connection objects becoz that currupts the pool the pool of objects in the broker.
In the servlet i start another object which is a thread(runnable). the new thread executes all the database operations and finally closes the statements and frees the connection.
Id this a problem?
thanks
dj


------------------
Vikas Aggarwal
Technology Associate
Shakun Global Networks
(http://www.vikinsa.com)
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. As vikas said - enclose your code in try - catch blocks, I usually enclose practically everything in doGet or doPost in a try-catch.
2. "In the servlet i start another object which is a thread(runnable). the new thread executes all the database operations and finally closes the statements and frees the connection. Is this a problem?"
- It certainly could be - if your servlet has to wait for this new Thread to run, why not use the servlet Thread itself to execute the database operations?
Bill

------------------
author of:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!