-->
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.  [ 4 posts ] 
Author Message
 Post subject: Multiple clicking problem
PostPosted: Mon Jun 13, 2005 5:52 am 
Newbie

Joined: Fri Mar 11, 2005 11:39 am
Posts: 5
Location: London
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.5

Mapping documents:

Code between sessionFactory.openSession() and session.close():
Using Springs' Open Session In View (OSIV) filter

In pageValidate() // pageValidate is called early in page construction

a call to a service method reattachEntity calls:

getHibernateTemplate().lock(getUserFromSession(),LockMode.NONE);

Full stack trace of any exception that occurs:
org.springframework.orm.hibernate3.HibernateSystemException
Illegal attempt to associate a collection with two open sessions; nested exception is org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions

org.hibernate.HibernateException
Illegal attempt to associate a collection with two open sessions

org.hibernate.collection.AbstractPersistentCollection.setCurrentSession(AbstractPersistentCollection.java:237)
org.hibernate.event.def.OnLockVisitor.processCollection(OnLockVisitor.java:40)
org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:104)
org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:64)
org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:58)
org.hibernate.event.def.AbstractVisitor.process(AbstractVisitor.java:129)
org.hibernate.event.def.AbstractReassociateEventListener.reassociate(AbstractReassociateEventListener.java:75)
org.hibernate.event.def.DefaultLockEventListener.onLock(DefaultLockEventListener.java:57)
org.hibernate.impl.SessionImpl.lock(SessionImpl.java:508)
org.springframework.orm.hibernate3.HibernateTemplate$10.doInHibernate(HibernateTemplate.java:519)
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:311)
org.springframework.orm.hibernate3.HibernateTemplate.lock(HibernateTemplate.java:517)
com.azudio.aptp.base.service.impl.APTPServiceImpl.reattachEntity(APTPServiceImpl.java:804)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:57)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
$Proxy63.reattachEntity(Unknown Source)
com.azudio.aptp.base.web.ProtectedBasePage.pageValidate(ProtectedBasePage.java:54)
com.azudio.aptp.base.web.student.StudentBasePage.pageValidate(StudentBasePage.java:28)
org.apache.tapestry.AbstractPage.firePageValidate(AbstractPage.java:558)
org.apache.tapestry.AbstractPage.validate(AbstractPage.java:333)
org.apache.tapestry.engine.RequestCycle.activate(RequestCycle.java:685)
org.apache.tapestry.engine.PageService.service(PageService.java:75)
org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:889)
org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:198)
org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:159)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
com.azudio.aptp.base.web.MessageFilter.doFilter(MessageFilter.java:36)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:172)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:552)

Also ...

org.apache.catalina.connector.ClientAbortException

java.net.SocketException: Broken pipe
java.net.SocketOutputStream.socketWrite0(Native Method)
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
java.net.SocketOutputStream.write(SocketOutputStream.java:136)
org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:747)
org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:403)
org.apache.coyote.http11.InternalOutputBuffer.flush(InternalOutputBuffer.java:305)
org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:978)
org.apache.coyote.Response.action(Response.java:182)
org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:322)
org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:293)
org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:85)
org.apache.tapestry.request.ResponseOutputStream.forceFlush(ResponseOutputStream.java:149)
org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:945)
org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:198)
org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:159)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
com.azudio.aptp.base.web.MessageFilter.doFilter(MessageFilter.java:36)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:172)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:552)

Name and version of the database you are using:MySQL 4.1.10

Application Framework: Tapestry 3.03, Tomcat 5.5.9, Spring 1.2

I'm having difficulty working out how I should solve this problem:
Repeatedly clicking on a link to the StudentHome page causes the above exception. I'm storing a detached student object in my session, as my StudentHome page begins I get the student and reattach it to a hib session opened by Springs' OSIV filter, I think I understand why this is happening, two requests are coming in at the same time and the first hib session is still open when the second is processing - is that right?

Another thing I've just noticed is that a single click works fine, doubles sometimes get both the broken pipe error & the 'Illegal attempt to associate a collection with two open sessions' error

So how would one get around this? Appreciate any help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 13, 2005 6:01 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
If you want to use Spring, go to their forum.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 13, 2005 6:13 am 
Newbie

Joined: Fri Mar 11, 2005 11:39 am
Posts: 5
Location: London
Seeing as hibernate is the application throwing the exception I though this would be the place to post, I'll post there. I just hope they dont respond with "If you want to use Hibernate, go to their forum"


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 13, 2005 6:28 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You simply discovered what every web developer should know: HttpSession is not thread-safe and multiple threads for the same HttpSession might run at any time. Google for that.


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