• 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

Current transaction is not in progress

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

I am using the JTA as explained in the hibernate documentation. The documentation says that if there is no transaction currently started, a new transaction will be opened upon the call to "getCurrentSession" method. however, when i call the following method "createCsa", it is throwing "Current transaction is not in progress" exception under WAS 6.

I'd appreciate if someone help me resolve this!

Hibernate version: 3.x

Code between sessionFactory.openSession() and session.close():

public Long createCsa(Csa csa) {
Session session = DAOFactory.getCsaSessionFactory().getCurrentSession();
Transaction tx=null;
Long id=null;

try {
tx = session.beginTransaction();

id=(Long)session.save(csa);

tx.commit();
}
catch (Exception e) {
if (tx!=null) tx.rollback();
System.out.println(e);
}
return id;
}

Full stack trace of any exception that occurs:

[8/18/06 13:33:11:549 CDT] 00000043 WebApp E SRVE0026E: [Servlet Error]-[action]: org.hibernate.HibernateException: Current transaction is not in progress
at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:67)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:508)
at cat.dds.csm.dao.CsaDAOImpl.createCsa(CsaDAOImpl.java:23)
at com.aravind.struts.action.LiteFormUserRegistrationAction.execute(LiteFormUserRegistrationAction.java:97)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2905)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:220)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:204)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java(Compiled Code))
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminaters(NewConnectionInitialReadCallback.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

Name and version of the database you are using: Oracle 10g
 
aravind yarram
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess the issues is that i am trying to open a current seesion before the begin of the transaction. I resolved this issues by demarcating the transactions in the session facade than in the DAO.

My new changed code looks like this

public Long createCsa(Csa csa) {
Session session = DAOFactory.getCsaSessionFactory().getCurrentSession();

Long id=null;

try {

id=(Long)session.save(csa);

}
catch (Exception e) {
//if (tx!=null) tx.rollback();
//System.out.println(e);
}
return id;
}

and the code in session facade looks lie this

Transaction tx=DAOFactory.getCsaSessionFactory().openSession().beginTransaction();

//call methods on various DAOs which constitue one logical unit fo work

tx.commit();

//tx.rollback() in case of exceptions
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic