-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Could not toggle autocommit
PostPosted: Tue Apr 22, 2008 3:57 am 
Newbie

Joined: Fri Mar 12, 2004 11:04 am
Posts: 10
Hi all,

Have this problem when I am calling StoreProcedure only.
So I have commented the begin and comit. But still the same error!

Any help will be appreciated ...

Hibernate version:
3.2.5 GA

Mapping documents:
Code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
   <session-factory>
      <property name="connection.datasource">
         java:comp/env/jdbc/crc
      </property>
      <property name="hibernate.dialect">
         org.hibernate.dialect.SQLServerDialect
      </property>
      <property name="show_sql">false</property>
      <property name="use_outer_join">true</property>
      <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
      <property name="hibernate.current_session_context_class">thread</property>

      <!-- mapping files -->
...

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


Code:
public class DAO {

   private static final Logger log = Logger.getAnonymousLogger();

   private static final ThreadLocal session = new ThreadLocal();

   private static final SessionFactory sessionFactory = new Configuration()
         .configure().buildSessionFactory();

   protected DAO() {
   }

   public static Session getSession() {
      Session session = (Session) DAO.session.get();
      if (session == null) {
         session = sessionFactory.openSession();
         DAO.session.set(session);
      }
      return session;
   }

   protected void begin() {
      getSession().beginTransaction();
   }

   protected void commit() {
      getSession().getTransaction().commit();
      }

   protected void rollback() {
      try {
         getSession().getTransaction().rollback();
      } catch (HibernateException e) {
         log.log(Level.WARNING, "Cannot rollback", e);
      }
      try {
         getSession().close();
      } catch (HibernateException e) {
         log.log(Level.WARNING, "Cannot close", e);
      }
      DAO.session.set(null);
   }

   public static void close() {
      getSession().close();
      DAO.session.set(null);
   }

}

Code:
public class Stat_Reports_DAO extends DAO {

   public Stat_Reports_DAO() {
   }

   
   public void SP4(String p1, String p2, String p3, String p4, String p5,
         String p6) throws DAOException {
      try {

         //begin();

         Timestamp ts1 = Timestamp.valueOf(p2 + " 00:00:00.0");
         Timestamp ts2 = Timestamp.valueOf(p3 + " 00:00:00.0");

         CallableStatement cs = getSession().connection().prepareCall("{call Sp_Stat_IP4(?,?,?,?,?,?)}");
         cs.setString(1, p1);
         cs.setTimestamp(2, ts1);
         cs.setTimestamp(3, ts2);
         cs.setString(4, p4);
         cs.setString(5, p5);
         cs.setInt(6, Integer.parseInt(p6));
         
         cs.execute();

         //commit();
         

      } catch (SQLException e) {
         //rollback();
         throw new DAOException("SQLException : SP4 ", e);
         
      } catch (HibernateException e) {
         //rollback();
         throw new DAOException("DAOExcep : SP4 ", e);
      } finally {
         close();
      }

   }


Name and version of the database you are using:
MS SQL 2005 SP1


Full stack trace of any exception that occurs:
Code:
2008-04-22 07:52:45 ERROR org.hibernate.transaction.JDBCTransaction:toggleAutoCommit (JDBCTransaction.java:198) (org.hibernate.transaction.JDBCTransaction) - Could not toggle autocommit
com.microsoft.sqlserver.jdbc.SQLServerException: New request is not allowed to start because it should come with valid transaction descriptor.
   at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
   at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(Unknown Source)
   at com.microsoft.sqlserver.jdbc.TDSParser.parse(Unknown Source)
   at com.microsoft.sqlserver.jdbc.TDSParser.parse(Unknown Source)
   at com.microsoft.sqlserver.jdbc.SQLServerConnection$1ConnectionCommand.doExecute(Unknown Source)
   at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
   at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
   at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectionCommand(Unknown Source)
   at com.microsoft.sqlserver.jdbc.SQLServerConnection.setAutoCommit(Unknown Source)
   at com.sun.gjc.spi.base.ConnectionHolder.setAutoCommit(ConnectionHolder.java:624)
   at org.hibernate.transaction.JDBCTransaction.toggleAutoCommit(JDBCTransaction.java:194)
   at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:142)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:115)
   at be.dzafer.hibernate.DAO.commit(DAO.java:38)
   at be.dzafer.hibernate.Stat_Reports_DAO.SP5(Stat_Reports_DAO.java:88)
   at be.dzafer.struts.action.Stat_Reports_DACT.prevReport(Stat_Reports_DACT.java:188)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
   at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
   at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
   at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
   at be.dzafer.filter.LoginFilter.doFilter(LoginFilter.java:49)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
   at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
   at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
   at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
   at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
   at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
   at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
   at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
   at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
   at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
   at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
   at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
   at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
   at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
   at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
   at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
   at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
   at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
   at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
2008-04-22 07:52:45 ERROR org.hibernate.transaction.JDBCTransaction:commit (JDBCTransaction.java:124) (org.hibernate.transaction.JDBCTransaction) - JDBC commit failed
com.microsoft.sqlserver.jdbc.SQLServerException: New request is not allowed to start because it should come with valid transaction descriptor.
   at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
   at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(Unknown Source)
   at com.microsoft.sqlserver.jdbc.TDSParser.parse(Unknown Source)
   at com.microsoft.sqlserver.jdbc.TDSParser.parse(Unknown Source)
   at com.microsoft.sqlserver.jdbc.SQLServerConnection$1ConnectionCommand.doExecute(Unknown Source)
   at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
   at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
   at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectionCommand(Unknown Source)
   at com.microsoft.sqlserver.jdbc.SQLServerConnection.commit(Unknown Source)
   at com.sun.gjc.spi.base.ConnectionHolder.commit(ConnectionHolder.java:228)
   at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:139)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:115)
   at be.dzafer.hibernate.DAO.commit(DAO.java:38)
   at be.dzafer.hibernate.Stat_Reports_DAO.SP5(Stat_Reports_DAO.java:88)
   at be.dzafer.struts.action.Stat_Reports_DACT.prevReport(Stat_Reports_DACT.java:188)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
   at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
   at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
   at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
   at be.dzafer.filter.LoginFilter.doFilter(LoginFilter.java:49)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
   at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
   at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
   at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
   at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
   at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
   at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
   at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
   at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
   at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
   at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
   at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
   at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
   at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
   at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
   at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
   at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
   at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
   at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)

[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 22, 2008 11:09 am 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Does call Sp_Stat_IP4 by any chance try to modify the database in any way?
Remember that Hibermnate only likes SELECT stored procedures, mapped to Hibernate objects.

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 02, 2008 4:41 am 
Newbie

Joined: Fri Mar 12, 2004 11:04 am
Posts: 10
Tested to latest Tomcat 5.5.26 and now it works!

(begin and commit must be still commented)

Works also on GlassFish v2ur1 and v2ur2.

Thank you Gonzao for your advice.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.