-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to catch StaleObjectStateException
PostPosted: Tue May 31, 2005 3:51 am 
Regular
Regular

Joined: Sat May 15, 2004 4:27 am
Posts: 79
Hi,

i am working with Hibernate 2.1.6, Jboss and Oracle. I created a versioning table, and i noticed an exception occurs many times :

2005-05-30 18:40:56,890 WARN [net.sf.hibernate.StaleObjectStateException] An operation failed due to stale data
net.sf.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) for fr.gouv.finances.copernic.mas.stf.persistance.hibernate.TacheElementaire instance with identifier: 1830
at net.sf.hibernate.persister.AbstractEntityPersister.check(AbstractEntityPersister.java:513)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:664)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:621)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2435)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2393)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2261)
at net.sf.hibernate.transaction.JTATransaction.commit(JTATransaction.java:52)
at fr.gouv.finances.copernic.mas.stf.persistance.hibernate.HibernateFactory.commitTransaction(HibernateFactory.java:188)
at fr.gouv.finances.copernic.mas.stf.persistance.service.session.SessionManagerHibernate.endTransaction(SessionManagerHibernate.java:103)
at fr.gouv.finances.copernic.mas.stf.service.planification.automate.ListeTacheAutomateImpl.updateStatutTacheTerminee(ListeTacheAutomateImpl.java:1249)
at fr.gouv.finances.copernic.mas.stf.service.planification.automate.ListeTacheAutomateImpl.updateStatutTache(ListeTacheAutomateImpl.java:752)
at fr.gouv.finances.copernic.mas.stf.service.planification.automate.ListeTacheAutomate.updateStatutTache(ListeTacheAutomate.java:119)
at sun.reflect.GeneratedMethodAccessor491.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:402)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:309)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:333)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:481)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:323)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:854)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:418)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)

I am understanding that another transaction updated the row i want to update. I am ok for the 'First Commit Wins'. So who can tell me how can
i manage the exception, and how can i catch it ? I tried that pieces of code :

} catch (HibernateException he) {
if (he.getCause() instanceof StaleObjectStateException) {
if (sLogger.isDebugEnabled()) {
sLogger.debug("////////////// La tache #" + pIdTache + " a ete modifiee par une autre transaction - FORCING (dans setIdService)\\\\\\\\\\\\\\\\\\");
}
}

It failed.

-----
Sebastien


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 11:41 pm 
Newbie

Joined: Wed Jul 20, 2005 11:23 pm
Posts: 2
you should be able to catch the exception around session flush call.

But say you catch that exception, how are you planning to proceed with the session or operation ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.