Announcement Announcement Module
Collapse
No announcement yet.
Session trouble in AbstractWizardFormController Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Session trouble in AbstractWizardFormController

    Hi,

    I am using the AbstractWizardFormController to go through a number of steps in order to edit information about an entity in my system (Bygning).
    In the processFinish method I save the object (using a DAO object utilizing Hibernate) and would like to show the updated information to the user. The last line of the processFinish method is
    Code:
     return new ModelAndView("bygning.htm");
    bygning.htm shows information about the currently selected bygning (which is Danish for "building").

    But somehow I seem to be missing a Session and Hibernate complains when it tries to lazy load some of the collections.

    Code:
    DEBUG - OpenSessionInViewFilter.lookupSessionFactory(198) | Using session factory 'sessionFactory' for OpenSessionInViewFilter
    DEBUG - AbstractBeanFactory.getBean(157) | Returning cached instance of singleton bean 'sessionFactory'
    DEBUG - AbstractBeanFactory.getObjectForSharedInstance(522) | Bean with name 'sessionFactory' is a factory bean
    DEBUG - OpenSessionInViewFilter.doFilterInternal(153) | Opening single Hibernate session in OpenSessionInViewFilter
    DEBUG - SessionFactoryUtils.getSession(329) | Opening Hibernate session
    DEBUG - TransactionSynchronizationManager.bindResource(142) | Bound value [org.springframework.orm.hibernate.SessionHolder@7a39ea] for key [net.sf.hibernate.impl.SessionFactoryImpl@da89a7] to thread [http-8080-Processor25]
    DEBUG - DispatcherServlet.doService(469) | DispatcherServlet with name 'fbb' received request for [/fbb/bygningredigering.htm]
    DEBUG - DispatcherServlet.getHandler(621) | Testing handler map [[email protected]004b78] in DispatcherServlet with name 'fbb'
    DEBUG - AbstractUrlHandlerMapping.getHandlerInternal(115) | Looking up handler for [/bygningredigering.htm]
    DEBUG - DispatcherServlet.getHandlerAdapter(641) | Testing handler adapter [org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter@5ad7b2]
    DEBUG - CachedIntrospectionResults.forClass(94) | Using cached introspection results for class [BygningWizardBean]
    DEBUG - BeanWrapperImpl.setPropertyValue(681) | About to invoke write method [public void RedigerBean.setBegrundelse(java.lang.String)] on object of class [BygningWizardBean]
    DEBUG - BeanWrapperImpl.setPropertyValue(689) | Invoked write method [public void RedigerBean.setBegrundelse(java.lang.String)] with value [kkk]
    errors = org.springframework.validation.BindException: BindException: 0 errors
    errors = org.springframework.validation.BindException: BindException: 0 errors
    DEBUG - TransactionSynchronizationManager.getResource(117) | Retrieved value [org.springframework.orm.hibernate.SessionHolder@7a39ea] for key [net.sf.hibernate.impl.SessionFactoryImpl@da89a7] bound to thread [http-8080-Processor25]
    DEBUG - HibernateTransactionManager.doGetTransaction(345) | Found thread-bound session [net.sf.hibernate.impl.SessionImpl@1b3e1c9] for Hibernate transaction
    DEBUG - AbstractPlatformTransactionManager.getTransaction(195) | Using transaction object [[email protected]b1]
    DEBUG - AbstractPlatformTransactionManager.getTransaction(267) | Creating new transaction
    DEBUG - HibernateTransactionManager.doBegin(412) | Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@69dff6]
    DEBUG - TransactionSynchronizationManager.bindResource(142) | Bound value [org.springframework.jdbc.datasource.ConnectionHolder@d8ced6] for key [org.apache.commons.dbcp.BasicDataSource@1e3940a] to thread [http-8080-Processor25]
    DEBUG - TransactionSynchronizationManager.initSynchronization(194) | Initializing transaction synchronization
    DEBUG - TransactionSynchronizationManager.getResource(117) | Retrieved value [org.springframework.orm.hibernate.SessionHolder@7a39ea] for key [net.sf.hibernate.impl.SessionFactoryImpl@da89a7] bound to thread [http-8080-Processor25]
    DEBUG - TransactionSynchronizationManager.getResource(117) | Retrieved value [org.springframework.orm.hibernate.SessionHolder@7a39ea] for key [net.sf.hibernate.impl.SessionFactoryImpl@da89a7] bound to thread [http-8080-Processor25]
    DEBUG - AbstractPlatformTransactionManager.triggerBeforeCommit(495) | Triggering beforeCommit synchronization
    DEBUG - AbstractPlatformTransactionManager.triggerBeforeCompletion(510) | Triggering beforeCompletion synchronization
    DEBUG - AbstractPlatformTransactionManager.commit(372) | Initiating transaction commit
    DEBUG - HibernateTransactionManager.doCommit(459) | Committing Hibernate transaction on session [net.sf.hibernate.impl.SessionImpl@1b3e1c9]
    DEBUG - AbstractPlatformTransactionManager.triggerAfterCompletion(540) | Triggering afterCompletion synchronization
    DEBUG - TransactionSynchronizationManager.clearSynchronization(234) | Clearing transaction synchronization
    DEBUG - TransactionSynchronizationManager.unbindResource(165) | Removed value [org.springframework.jdbc.datasource.ConnectionHolder@d8ced6] for key [org.apache.commons.dbcp.BasicDataSource@1e3940a] from thread [http-8080-Processor25]
    DEBUG - HibernateTransactionManager.doCleanupAfterCompletion(541) | Not closing pre-bound Hibernate session [net.sf.hibernate.impl.SessionImpl@1b3e1c9] after transaction
    DEBUG - TransactionSynchronizationManager.getResource(117) | Retrieved value [org.springframework.orm.hibernate.SessionHolder@7a39ea] for key [net.sf.hibernate.impl.SessionFactoryImpl@da89a7] bound to thread [http-8080-Processor25]
    DEBUG - HibernateTransactionManager.doGetTransaction(345) | Found thread-bound session [net.sf.hibernate.impl.SessionImpl@1b3e1c9] for Hibernate transaction
    DEBUG - AbstractPlatformTransactionManager.getTransaction(195) | Using transaction object [[email protected]dce]
    DEBUG - AbstractPlatformTransactionManager.getTransaction(267) | Creating new transaction
    DEBUG - HibernateTransactionManager.doBegin(412) | Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@69dff6]
    DEBUG - TransactionSynchronizationManager.bindResource(142) | Bound value [org.springframework.jdbc.datasource.ConnectionHolder@10a098] for key [org.apache.commons.dbcp.BasicDataSource@1e3940a] to thread [http-8080-Processor25]
    DEBUG - TransactionSynchronizationManager.initSynchronization(194) | Initializing transaction synchronization
    DEBUG - TransactionSynchronizationManager.getResource(117) | Retrieved value [org.springframework.orm.hibernate.SessionHolder@7a39ea] for key [net.sf.hibernate.impl.SessionFactoryImpl@da89a7] bound to thread [http-8080-Processor25]
    DEBUG - TransactionSynchronizationManager.getResource(117) | Retrieved value [org.springframework.orm.hibernate.SessionHolder@7a39ea] for key [net.sf.hibernate.impl.SessionFactoryImpl@da89a7] bound to thread [http-8080-Processor25]
    DEBUG - AbstractPlatformTransactionManager.triggerBeforeCommit(495) | Triggering beforeCommit synchronization
    DEBUG - AbstractPlatformTransactionManager.triggerBeforeCompletion(510) | Triggering beforeCompletion synchronization
    DEBUG - AbstractPlatformTransactionManager.commit(372) | Initiating transaction commit
    DEBUG - HibernateTransactionManager.doCommit(459) | Committing Hibernate transaction on session [net.sf.hibernate.impl.SessionImpl@1b3e1c9]
    DEBUG - AbstractPlatformTransactionManager.triggerAfterCompletion(540) | Triggering afterCompletion synchronization
    DEBUG - TransactionSynchronizationManager.clearSynchronization(234) | Clearing transaction synchronization
    DEBUG - TransactionSynchronizationManager.unbindResource(165) | Removed value [org.springframework.jdbc.datasource.ConnectionHolder@10a098] for key [org.apache.commons.dbcp.BasicDataSource@1e3940a] from thread [http-8080-Processor25]
    DEBUG - HibernateTransactionManager.doCleanupAfterCompletion(541) | Not closing pre-bound Hibernate session [net.sf.hibernate.impl.SessionImpl@1b3e1c9] after transaction
    DEBUG - DispatcherServlet.doService(558) | Will render view in DispatcherServlet with name 'fbb'
    INFO - AbstractCachingViewResolver.resolveViewName(81) | Cached view 'bygning.htm'
    DEBUG - AbstractView.render(225) | Rendering view with name 'bygning.htm' with model {} and static attributes {}
    DEBUG - DispatcherServlet.doService(469) | DispatcherServlet with name 'fbb' received request for [/fbb/bygning.htm]
    DEBUG - DispatcherServlet.getHandler(621) | Testing handler map [[email protected]004b78] in DispatcherServlet with name 'fbb'
    DEBUG - AbstractUrlHandlerMapping.getHandlerInternal(115) | Looking up handler for [/bygning.htm]
    DEBUG - DispatcherServlet.getHandlerAdapter(641) | Testing handler adapter [org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter@5ad7b2]
    DEBUG - TransactionSynchronizationManager.getResource(117) | Retrieved value [org.springframework.orm.hibernate.SessionHolder@7a39ea] for key [net.sf.hibernate.impl.SessionFactoryImpl@da89a7] bound to thread [http-8080-Processor25]
    DEBUG - TransactionSynchronizationManager.getResource(117) | Retrieved value [org.springframework.orm.hibernate.SessionHolder@7a39ea] for key [net.sf.hibernate.impl.SessionFactoryImpl@da89a7] bound to thread [http-8080-Processor25]
    DEBUG - TransactionSynchronizationManager.getResource(117) | Retrieved value [org.springframework.orm.hibernate.SessionHolder@7a39ea] for key [net.sf.hibernate.impl.SessionFactoryImpl@da89a7] bound to thread [http-8080-Processor25]
    DEBUG - DispatcherServlet.doService(558) | Will render view in DispatcherServlet with name 'fbb'
    DEBUG - AbstractView.render(225) | Rendering view with name '/WEB-INF/jsp/bygning.jsp' with model {model={bygning=Bygningsværk@e62f6, sager=[sager.FredningsBevaringsSag@1d66aa9]}} and static attributes {}
    DEBUG - InternalResourceView.exposeModelAsRequestAttributes(121) | Added model object 'model' of type [java.util.HashMap] to request in InternalResourceView '/WEB-INF/jsp/bygning.jsp'
    ERROR - LazyInitializationException.<init>&#40;25&#41; | Failed to lazily initialize a collection - no session or session was closed
    net.sf.hibernate.LazyInitializationException&#58; Failed to lazily initialize a collection - no session or session was closed
    	at net.sf.hibernate.collection.PersistentCollection.initialize&#40;PersistentCollection.java&#58;209&#41;
    	at net.sf.hibernate.collection.PersistentCollection.read&#40;PersistentCollection.java&#58;71&#41;
    	at net.sf.hibernate.collection.List.iterator&#40;List.java&#58;103&#41;
    	at org.apache.taglibs.standard.tag.common.core.ForEachSupport.toForEachIterator&#40;ForEachSupport.java&#58;326&#41;
    	at org.apache.taglibs.standard.tag.common.core.ForEachSupport.supportedTypeForEachIterator&#40;ForEachSupport.java&#58;204&#41;
    	at org.apache.taglibs.standard.tag.common.core.ForEachSupport.prepare&#40;ForEachSupport.java&#58;138&#41;
    	at javax.servlet.jsp.jstl.core.LoopTagSupport.doStartTag&#40;LoopTagSupport.java&#58;262&#41;
    	at org.apache.taglibs.standard.tag.el.core.ForEachTag.doStartTag&#40;ForEachTag.java&#58;69&#41;
    	at org.apache.jsp.WEB_002dINF.jsp.bbroplysninger_jsp._jspService&#40;bbroplysninger_jsp.java&#58;124&#41;
    	at org.apache.jasper.runtime.HttpJspBase.service&#40;HttpJspBase.java&#58;94&#41;
    	at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;802&#41;
    	at org.apache.jasper.servlet.JspServletWrapper.service&#40;JspServletWrapper.java&#58;324&#41;
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile&#40;JspServlet.java&#58;292&#41;
    	at org.apache.jasper.servlet.JspServlet.service&#40;JspServlet.java&#58;236&#41;
    	at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;802&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter&#40;ApplicationFilterChain.java&#58;237&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter&#40;ApplicationFilterChain.java&#58;157&#41;
    	at org.apache.catalina.core.ApplicationDispatcher.invoke&#40;ApplicationDispatcher.java&#58;704&#41;
    	at org.apache.catalina.core.ApplicationDispatcher.doInclude&#40;ApplicationDispatcher.java&#58;590&#41;
    	at org.apache.catalina.core.ApplicationDispatcher.include&#40;ApplicationDispatcher.java&#58;510&#41;
    	at org.apache.jasper.runtime.JspRuntimeLibrary.include&#40;JspRuntimeLibrary.java&#58;966&#41;
    	at org.apache.jsp.WEB_002dINF.jsp.bygning_jsp._jspx_meth_core_when_2&#40;bygning_jsp.java&#58;802&#41;
    	at org.apache.jsp.WEB_002dINF.jsp.bygning_jsp._jspx_meth_core_choose_1&#40;bygning_jsp.java&#58;768&#41;
    	at org.apache.jsp.WEB_002dINF.jsp.bygning_jsp._jspService&#40;bygning_jsp.java&#58;301&#41;
    	at org.apache.jasper.runtime.HttpJspBase.service&#40;HttpJspBase.java&#58;94&#41;
    	at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;802&#41;
    	at org.apache.jasper.servlet.JspServletWrapper.service&#40;JspServletWrapper.java&#58;324&#41;
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile&#40;JspServlet.java&#58;292&#41;
    	at org.apache.jasper.servlet.JspServlet.service&#40;JspServlet.java&#58;236&#41;
    	at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;802&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter&#40;ApplicationFilterChain.java&#58;237&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter&#40;ApplicationFilterChain.java&#58;157&#41;
    	at org.apache.catalina.core.ApplicationDispatcher.invoke&#40;ApplicationDispatcher.java&#58;704&#41;
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest&#40;ApplicationDispatcher.java&#58;474&#41;
    	at org.apache.catalina.core.ApplicationDispatcher.doForward&#40;ApplicationDispatcher.java&#58;409&#41;
    	at org.apache.catalina.core.ApplicationDispatcher.forward&#40;ApplicationDispatcher.java&#58;312&#41;
    	at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel&#40;InternalResourceView.java&#58;91&#41;
    	at org.springframework.web.servlet.view.AbstractView.render&#40;AbstractView.java&#58;241&#41;
    	at org.springframework.web.servlet.DispatcherServlet.render&#40;DispatcherServlet.java&#58;678&#41;
    	at org.springframework.web.servlet.DispatcherServlet.doService&#40;DispatcherServlet.java&#58;562&#41;
    	at org.springframework.web.servlet.FrameworkServlet.service&#40;FrameworkServlet.java&#58;321&#41;
    	at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;802&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter&#40;ApplicationFilterChain.java&#58;237&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter&#40;ApplicationFilterChain.java&#58;157&#41;
    	at org.apache.catalina.core.ApplicationDispatcher.invoke&#40;ApplicationDispatcher.java&#58;704&#41;
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest&#40;ApplicationDispatcher.java&#58;474&#41;
    	at org.apache.catalina.core.ApplicationDispatcher.doForward&#40;ApplicationDispatcher.java&#58;409&#41;
    	at org.apache.catalina.core.ApplicationDispatcher.forward&#40;ApplicationDispatcher.java&#58;312&#41;
    	at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel&#40;InternalResourceView.java&#58;91&#41;
    	at org.springframework.web.servlet.view.AbstractView.render&#40;AbstractView.java&#58;241&#41;
    	at org.springframework.web.servlet.DispatcherServlet.render&#40;DispatcherServlet.java&#58;678&#41;
    	at org.springframework.web.servlet.DispatcherServlet.doService&#40;DispatcherServlet.java&#58;562&#41;
    	at org.springframework.web.servlet.FrameworkServlet.service&#40;FrameworkServlet.java&#58;321&#41;
    	at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;802&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter&#40;ApplicationFilterChain.java&#58;237&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter&#40;ApplicationFilterChain.java&#58;157&#41;
    	at org.springframework.orm.hibernate.support.OpenSessionInViewFilter.doFilterInternal&#40;OpenSessionInViewFilter.java&#58;170&#41;
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter&#40;OncePerRequestFilter.java&#58;73&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter&#40;ApplicationFilterChain.java&#58;186&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter&#40;ApplicationFilterChain.java&#58;157&#41;
    	at org.apache.catalina.core.StandardWrapperValve.invoke&#40;StandardWrapperValve.java&#58;214&#41;
    	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;104&#41;
    	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;520&#41;
    	at org.apache.catalina.core.StandardContextValve.invokeInternal&#40;StandardContextValve.java&#58;198&#41;
    	at org.apache.catalina.core.StandardContextValve.invoke&#40;StandardContextValve.java&#58;152&#41;
    	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;104&#41;
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke&#40;AuthenticatorBase.java&#58;540&#41;
    	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;102&#41;
    	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;520&#41;
    	at org.apache.catalina.core.StandardHostValve.invoke&#40;StandardHostValve.java&#58;137&#41;
    	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;104&#41;
    	at org.apache.catalina.valves.ErrorReportValve.invoke&#40;ErrorReportValve.java&#58;118&#41;
    	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;102&#41;
    	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;520&#41;
    	at org.apache.catalina.core.StandardEngineValve.invoke&#40;StandardEngineValve.java&#58;109&#41;
    	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;104&#41;
    	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;520&#41;
    	at org.apache.catalina.core.ContainerBase.invoke&#40;ContainerBase.java&#58;929&#41;
    	at org.apache.coyote.tomcat5.CoyoteAdapter.service&#40;CoyoteAdapter.java&#58;160&#41;
    	at org.apache.coyote.http11.Http11Processor.process&#40;Http11Processor.java&#58;799&#41;
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection&#40;Http11Protocol.java&#58;705&#41;
    	at org.apache.tomcat.util.net.TcpWorkerThread.runIt&#40;PoolTcpEndpoint.java&#58;577&#41;
    	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run&#40;ThreadPool.java&#58;683&#41;
    	at java.lang.Thread.run&#40;Thread.java&#58;534&#41;
    Accessing "bygning.htm" normally (ie. not as the last step in the AbstractWizardFormController) works without problems.

    Does anybody have a clue on what I am doing wrong?

    Best regards,

    Jørgen

  • #2
    Is "bygning.htm" the wizard? It's not completely clear to me from your post.

    If so, can you redirect to an edit page as the last line in processFinish instead of trying to display the wizard again -- which I don't think would work?

    e.g. last line of processFinish...

    return new ModelAndView(new RedirectView("edit-bygning.htm"), model);

    where model is a Map that contains the id of the building you just created in the wizard.


    In AbstractWizardFormController's processFormSubmission method, the wizard state is removed from session, but not restored into the session if you're finishing the wizard.

    Is this what's happening when you say "...I seem to be missing a Session.." ?

    Comment


    • #3
      Originally posted by gmatthews
      Is "bygning.htm" the wizard? It's not completely clear to me from your post.
      "bygning.htm" shows the information about the building and "edit-bygning" allows one to edit information about a building. "edit-building.htm" is the wizard.

      Originally posted by gmatthews
      If so, can you redirect to an edit page as the last line in processFinish instead of trying to display the wizard again -- which I don't think would work?

      e.g. last line of processFinish...

      return new ModelAndView(new RedirectView("edit-bygning.htm"), model);

      where model is a Map that contains the id of the building you just created in the wizard.
      That's it! Adding a RedirectView did it - it works. The code now looks like this
      Code:
      return new ModelAndView&#40;new RedirectView&#40;"bygning.htm"&#41;&#41;;
      Thanks a lot

      Cheers from snowy Denmark,

      Jørgen

      Comment

      Working...
      X