0

org.hibernate.TransactionException: Transaction not successfully started

asked 2009-03-05 17:12:23 +0800

bob007 gravatar image bob007
384 3 4

updated 2009-03-16 14:48:57 +0800

*** ANSWERED/SOLVED ***

Hi all,

I had a problem with a class with a many-to-one relation not comiting : here

Since then i manage my transaction myself and my application seem to work well (in test at least). But i got this exception (seem like its coming from ZK invokeExecutionCleanups and ZK OpenSessionInViewListener) in console and i asking myself why ?

I begin a new transaction each time like that:

   public void saveOrUpdate(HeuresEffectuees desHeuresEffectuees) {
      Session sess = currentSession();
      Transaction tx = sess.beginTransaction();
      sess.saveOrUpdate(desHeuresEffectuees);
      tx.commit();
   }


I got this Exception in console but my application dont stop running :


2009-03-05 11:45:14 org.zkoss.zk.ui.util.Configuration invokeExecutionCleanups:831
GRAVE: Failed to invoke class org.zkoss.zkplus.hibernate.OpenSessionInViewListener

org.hibernate.TransactionException: Transaction not successfully started
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:131)
at org.zkoss.zkplus.hibernate.OpenSessionInViewListener.cleanup(OpenSessionInViewListener.java:65)
at org.zkoss.zk.ui.util.Configuration.invokeExecutionCleanups(Configuration.java:828)

at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1053)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:480)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:370)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:379)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)


Since my application continue is it a problem ?

delete flag offensive retag edit

17 Replies

Sort by ยป oldest newest

answered 2009-03-05 20:29:25 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

@bob007

Hi Bob,

sorry but this is absolut not for the ZKoss Forum. Have a look at the Hibernate Forums.
There you became surely the right help.

But: Please do a try/catch. What should happens when the commit is failed???

not tested code

try{
    Session sess = currentSession();
    Transaction tx = sess.beginTransaction();
    sess.saveOrUpdate(desHeuresEffectuees);
    tx.commit();
} catch (Exception e){
     sysout(e);
     tx.rollback();
     sess.close(); ??? 
}

whishes
Stephan

link publish delete flag offensive edit

answered 2009-03-05 20:47:02 +0800

bob007 gravatar image bob007
384 3 4

updated 2009-03-05 20:53:19 +0800

I don't think its my commits who raise the exception.
It seem more like its the ZK invokeExecutionCleanups and ZK OpenSessionInViewListener.

2009-03-05 11:45:14 org.zkoss.zk.ui.util.Configuration invokeExecutionCleanups:831 
GRAVE: Failed to invoke class org.zkoss.zkplus.hibernate.OpenSessionInViewListener 
...
at org.zkoss.zkplus.hibernate.OpenSessionInViewListener.cleanup(OpenSessionInViewListener.java:65) 
at org.zkoss.zk.ui.util.Configuration.invokeExecutionCleanups(Configuration.java:828)
...

link publish delete flag offensive edit

answered 2009-03-05 23:26:34 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2009-03-05 23:28:10 +0800

hmmm,

sorry i don't know. My hibernate is managed by spring.

link publish delete flag offensive edit

answered 2009-03-06 01:50:53 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

bob,
the exception recall me something, I think you should not 'beginTransaction' for currentSession and 'commit' it.
because OpenSessionInViewListener already did it.

About many-to-on didn't commit issue, I am wondering , it is a hibernate( mapping configuration ) issue or ZK event thread issue.
Did you disable the event thread of ZK of your application.

link publish delete flag offensive edit

answered 2009-03-06 03:35:04 +0800

bob007 gravatar image bob007
384 3 4

updated 2009-03-06 03:44:01 +0800

@dennis

thanks for your answer,

No i didnt disable the event thread of ZK and my other commiting are working.
Are you sure i should not use transaction begin/commit in ZK ?
Is there another way to force ZK to commit then ?

I really really dont know what to do now, i'm on this since a few days and my work start to get late.

link publish delete flag offensive edit

answered 2009-03-06 06:12:23 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

updated 2009-03-06 06:13:50 +0800

bobo,
I didn't have enough information(the code/the logic) about your application to know what is the problem,
and I still think this is the usage problem of hibernate.

1.call session.flush() before saveOrUpdate();(don't call beginTransaction() and commit, )
2.can you try to disable event thread to see if it work or not.

if still no work, please post a reproducible code here(as simple as possible, please) (there will be many files in you case)

/Dennis

link publish delete flag offensive edit

answered 2009-03-06 06:16:09 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

Please also check if there is any exception when you do the update , because exception will trigger rollback.

link publish delete flag offensive edit

answered 2009-03-06 20:45:20 +0800

bob007 gravatar image bob007
384 3 4

updated 2009-03-07 21:54:54 +0800

@Dennis

Thanks for your answer,

No I don't get any exception for the update.
Are you totally sure I can't / shouldn't use transaction begin/commit ?
I wanted as many confirmation as possible because only two people answered me : one said Yes and the other said No.

I was wondering if I do it with transaction begin/commit :
Since the problem for org.zkoss.zkplus.hibernate.OpenSessionInViewListener.cleanup
is "Transaction not successfully started" maybe i put a sess.beginTransaction(); just after my commits maybe it will solve the problem ?

Can it work ?
Steve

link publish delete flag offensive edit

answered 2009-03-09 01:12:45 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

updated 2009-03-09 01:13:20 +0800

Bob,
I don't have your application and did have enough information about the application logic/detail.
It will spend me too much time to "GUESS" what happened in your application.
Maybe a small tricky code/configuration cause this error, but I don't know since I am not a member in the project, I don't have the code to trace.
So, If you can do some filtering to remove some unnecessary code, provide a simple reproducible code (doesn't have many business logic/object)
It will help me to help you solve the problem.
:)
/Dennis

link publish delete flag offensive edit

answered 2009-03-09 09:33:01 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

Bob, please also provide the implementation of hashCode() and equals() of the persistence object HeuresEffectuees

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-03-05 17:12:23 +0800

Seen: 3,293 times

Last updated: Aug 28 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More