• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Check the active transcation to clear the session?

 
balaji anatha padmanaban
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

When I am navigating from one JSP to another JSP page I am getting error like "Error clearing sessionflush is not valid without active transaction".

This is below code
public void clearHibernateSesion() throws Exception {
try{

HibernateUtil.closeSession();
} catch (Exception e) {
LOG.error(e.getMessage());
throw new ProcessException(LSConstants.OTHER_ERROR);
}
In this code how I have to modifiy to avoid the exception?

Please explain
Thanks.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I guess the first question I have to ask is 'do you have an open transaction?'

Without an open transaction, you can't do these various operations on the Session. I'm guessing that you've committed the transaction at some point, either explicitly in code, or perhaps because another operation has closed it, such as a RuntimeException or something.

The solution is to keep your sessions/transactions open longer. The Open Session in View pattern is typically the way to go in web apps that aren't overly complex.

-Cameron McKenzie
[ September 07, 2008: Message edited by: Cameron Wallace McKenzie ]
 
balaji anatha padmanaban
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there is any logic I can add in existing code itself to avoid the exception.

Thanks.
 
balaji anatha padmanaban
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible to check the transcation at the present coce itself?
Thanks
 
in Mkumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess , you need to check whether a transaction is open or not in current sesion then close transaction..

Manoj
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic