Announcement Announcement Module
Collapse
No announcement yet.
OpenSessionInViewInterceptor - an exception? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OpenSessionInViewInterceptor - an exception?

    I am using OpenSessionInViewInterceptor. I get this weird behaviour. Submiting login information (username, pass), getting right user with DAO (TransactionProxyFB, HibernateTM, PROPAGATION_SUPPORTS), rendering page with JSTL, page displays and all looks ok. But when I hit F5 button to refresh page (just to see what happens), my interceptor crashes, since SessionFactoryUtils.getSession already bounds Session to thread and therefore TransactionSynchronizationManager.bindResource already has a binded object under the sessionFactory key - resulting in exception.

    What seems to be the problem?
    Why does SessionFactoryUtils.getSession bind session?

    I don't see TransactionSynchronizationManager clearing transaction synchronization. But this probably isn't important since second request is different thread.

    Thanx,
    Ales

    //------------------- log trace ---------------
    OpenSessionInViewInterceptor.java - Opening single Hibernate session in OpenSessionInViewInterceptor
    SessionFactoryUtils.java - Opening Hibernate session
    TransactionSynchronizationManager.java - Bound value [org.springframework.orm.hibernate.SessionHolder@79 6e1c] for key [net.sf.hibernate.impl.SessionFactoryImpl@abbec4] to thread [HttpProcessor[8080][1]]
    TransactionSynchronizationManager.java - Retrieved value [org.springframework.orm.hibernate.SessionHolder@79 6e1c] for key [net.sf.hibernate.impl.SessionFactoryImpl@abbec4] bound to thread [HttpProcessor[8080][1]]
    OpenSessionInViewInterceptor.java - Flushing single Hibernate session in OpenSessionInViewInterceptor
    PropertiesBeanDefinitionReader.java - Found bean name 'loginForm'
    PropertiesBeanDefinitionReader.java - MutablePropertyValues: length=1; PropertyValue: name='url'; value=[login.layout]
    PropertiesBeanDefinitionReader.java - Found bean name 'loginForm'
    PropertiesBeanDefinitionReader.java - Found bean name 'parentTilesView'
    PropertiesBeanDefinitionReader.java - MutablePropertyValues: length=1; PropertyValue: name='contentType'; value=[text/html;charset=Windows-1250]
    PropertiesBeanDefinitionReader.java - Found bean name 'welcomeView'
    PropertiesBeanDefinitionReader.java - MutablePropertyValues: length=1; PropertyValue: name='url'; value=[welcome.layout]
    PropertiesBeanDefinitionReader.java - Found bean name 'parentTilesView'
    PropertiesBeanDefinitionReader.java - Found bean name 'welcomeView'
    DefaultListableBeanFactory.java - Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [loginForm,parentTilesView,welcomeView]; parent=<org.springframework.web.context.support.Xm lWebApplicationContext: displayName=[XmlWebApplicationContext for namespace 'ecos-servlet']; startup date=[Mon Aug 23 14:06:10 CEST 2004]; parent=[org.springframework.web.context.support.XmlWebAppl icationContext: displayName=[Root XmlWebApplicationContext]; startup date=[Mon Aug 23 14:05:48 CEST 2004]; root of ApplicationContext hierarchy; config locations=[/WEB-INF/applicationContext.xml,/WEB-INF/connectors.xml]; ]; config locations=[/WEB-INF/ecos-servlet.xml]; >]
    AbstractBeanFactory.java - Creating shared instance of singleton bean 'loginForm'
    AbstractAutowireCapableBeanFactory.java - Creating instance of bean 'loginForm' with merged definition [Root bean with class [org.springframework.web.servlet.view.tiles.TilesJs tlView]]
    CachedIntrospectionResults.java - Getting BeanInfo for class [org.springframework.web.servlet.view.tiles.TilesJs tlView]
    CachedIntrospectionResults.java - Caching PropertyDescriptors for class [org.springframework.web.servlet.view.tiles.TilesJs tlView]
    CachedIntrospectionResults.java - Found property 'applicationContext' of type [interface org.springframework.context.ApplicationContext]; editor=[null]
    CachedIntrospectionResults.java - Found property 'attributes' of type [class java.util.Properties]; editor=[null]
    CachedIntrospectionResults.java - Found property 'attributesCSV' of type [class java.lang.String]; editor=[null]
    CachedIntrospectionResults.java - Found property 'attributesMap' of type [interface java.util.Map]; editor=[null]
    CachedIntrospectionResults.java - Found property 'beanName' of type [class java.lang.String]; editor=[null]
    CachedIntrospectionResults.java - Found property 'class' of type [class java.lang.Class]; editor=[null]
    CachedIntrospectionResults.java - Found property 'contentType' of type [class java.lang.String]; editor=[null]
    CachedIntrospectionResults.java - Found property 'requestContextAttribute' of type [class java.lang.String]; editor=[null]
    CachedIntrospectionResults.java - Found property 'staticAttributes' of type [interface java.util.Map]; editor=[null]
    CachedIntrospectionResults.java - Found property 'url' of type [class java.lang.String]; editor=[null]
    CachedIntrospectionResults.java - Class [org.springframework.web.servlet.view.tiles.TilesJs tlView] is cache-safe
    BeanWrapperImpl.java - About to invoke write method [public void org.springframework.web.servlet.view.AbstractView. setContentType(java.lang.String)] on object of class [org.springframework.web.servlet.view.tiles.TilesJs tlView]
    BeanWrapperImpl.java - Invoked write method [public void org.springframework.web.servlet.view.AbstractView. setContentType(java.lang.String)] with value [text/html;charset=Windows-1250]
    BeanWrapperImpl.java - About to invoke write method [public void org.springframework.web.servlet.view.AbstractUrlBa sedView.setUrl(java.lang.String)] on object of class [org.springframework.web.servlet.view.tiles.TilesJs tlView]
    BeanWrapperImpl.java - Invoked write method [public void org.springframework.web.servlet.view.AbstractUrlBa sedView.setUrl(java.lang.String)] with value [login.layout]
    AbstractAutowireCapableBeanFactory.java - Invoking setBeanName() on BeanNameAware bean 'loginForm'
    AbstractAutowireCapableBeanFactory.java - Invoking BeanPostProcessors before initialization of bean 'loginForm'
    AbstractAutowireCapableBeanFactory.java - Invoking BeanPostProcessors after initialization of bean 'loginForm'
    AbstractBeanFactory.java - Creating shared instance of singleton bean 'parentTilesView'
    AbstractAutowireCapableBeanFactory.java - Creating instance of bean 'parentTilesView' with merged definition [Root bean with class [org.springframework.web.servlet.view.tiles.TilesJs tlView]]
    CachedIntrospectionResults.java - Using cached introspection results for class [org.springframework.web.servlet.view.tiles.TilesJs tlView]
    BeanWrapperImpl.java - About to invoke write method [public void org.springframework.web.servlet.view.AbstractView. setContentType(java.lang.String)] on object of class [org.springframework.web.servlet.view.tiles.TilesJs tlView]
    BeanWrapperImpl.java - Invoked write method [public void org.springframework.web.servlet.view.AbstractView. setContentType(java.lang.String)] with value [text/html;charset=Windows-1250]
    AbstractAutowireCapableBeanFactory.java - Invoking setBeanName() on BeanNameAware bean 'parentTilesView'
    AbstractAutowireCapableBeanFactory.java - Invoking BeanPostProcessors before initialization of bean 'parentTilesView'
    AbstractAutowireCapableBeanFactory.java - Invoking BeanPostProcessors after initialization of bean 'parentTilesView'
    AbstractBeanFactory.java - Creating shared instance of singleton bean 'welcomeView'
    AbstractAutowireCapableBeanFactory.java - Creating instance of bean 'welcomeView' with merged definition [Root bean with class [org.springframework.web.servlet.view.tiles.TilesJs tlView]]
    CachedIntrospectionResults.java - Using cached introspection results for class [org.springframework.web.servlet.view.tiles.TilesJs tlView]
    BeanWrapperImpl.java - About to invoke write method [public void org.springframework.web.servlet.view.AbstractView. setContentType(java.lang.String)] on object of class [org.springframework.web.servlet.view.tiles.TilesJs tlView]
    BeanWrapperImpl.java - Invoked write method [public void org.springframework.web.servlet.view.AbstractView. setContentType(java.lang.String)] with value [text/html;charset=Windows-1250]
    BeanWrapperImpl.java - About to invoke write method [public void org.springframework.web.servlet.view.AbstractUrlBa sedView.setUrl(java.lang.String)] on object of class [org.springframework.web.servlet.view.tiles.TilesJs tlView]
    BeanWrapperImpl.java - Invoked write method [public void org.springframework.web.servlet.view.AbstractUrlBa sedView.setUrl(java.lang.String)] with value [welcome.layout]
    AbstractAutowireCapableBeanFactory.java - Invoking setBeanName() on BeanNameAware bean 'welcomeView'
    AbstractAutowireCapableBeanFactory.java - Invoking BeanPostProcessors before initialization of bean 'welcomeView'
    AbstractAutowireCapableBeanFactory.java - Invoking BeanPostProcessors after initialization of bean 'welcomeView'
    AbstractBeanFactory.java - Returning cached instance of singleton bean 'loginForm'
    ResourceBundleThemeSource.java - Theme created: name=theme, baseName=theme
    ReloadableResourceBundleMessageSource.java - Loading properties for filename [WEB-INF/messages_sl] with charset 'Windows-1250'
    AbstractMessageSource.java - Creating MessageFormat for pattern [Prijava] and locale 'sl'
    AbstractMessageSource.java - Creating MessageFormat for pattern [Uporabniško ime] and locale 'sl'
    AbstractMessageSource.java - Creating MessageFormat for pattern [Geslo] and locale 'sl'
    AbstractMessageSource.java - Creating MessageFormat for pattern [Pošlji] and locale 'sl'
    AbstractMessageSource.java - Creating MessageFormat for pattern [Zbriši] and locale 'sl'
    TransactionSynchronizationManager.java - Removed value [org.springframework.orm.hibernate.SessionHolder@79 6e1c] for key [net.sf.hibernate.impl.SessionFactoryImpl@abbec4] from thread [HttpProcessor[8080][1]]
    OpenSessionInViewInterceptor.java - Closing single Hibernate session in OpenSessionInViewInterceptor
    SessionFactoryUtils.java - Closing Hibernate session
    AbstractApplicationContext.java - Publishing event in context [XmlWebApplicationContext for namespace 'ecos-servlet']: RequestHandledEvent: url=[/ecos/login.htm]; time=[1719ms]; client=[127.0.0.1]; method=[GET]; servlet=[ecos]; session=[3090D59C0BD28DEF46E12BFA5BD3E277]; user=[null]; status=[OK]
    AbstractApplicationContext.java - Publishing event in context [Root XmlWebApplicationContext]: RequestHandledEvent: url=[/ecos/login.htm]; time=[1719ms]; client=[127.0.0.1]; method=[GET]; servlet=[ecos]; session=[3090D59C0BD28DEF46E12BFA5BD3E277]; user=[null]; status=[OK]
    OpenSessionInViewInterceptor.java - Opening single Hibernate session in OpenSessionInViewInterceptor
    SessionFactoryUtils.java - Opening Hibernate session
    TransactionSynchronizationManager.java - Bound value [org.springframework.orm.hibernate.SessionHolder@bc 312f] for key [net.sf.hibernate.impl.SessionFactoryImpl@abbec4] to thread [HttpProcessor[8080][1]]
    TransactionAspectSupport.java - Getting transaction for method 'findUser' in class [com.generalynx.ecos.data.dao.IBasicDAO]
    JdbcTransactionObjectSupport.java - JDBC 3.0 Savepoint class is available
    TransactionSynchronizationManager.java - Retrieved value [org.springframework.orm.hibernate.SessionHolder@bc 312f] for key [net.sf.hibernate.impl.SessionFactoryImpl@abbec4] bound to thread [HttpProcessor[8080][1]]
    HibernateTransactionManager.java - Found thread-bound session [net.sf.hibernate.impl.SessionImpl@5d45d9] for Hibernate transaction
    AbstractPlatformTransactionManager.java - Using transaction object [org.springframework.orm.hibernate.HibernateTransac tionObject@94aa42]
    TransactionSynchronizationManager.java - Initializing transaction synchronization
    TransactionSynchronizationManager.java - Retrieved value [org.springframework.orm.hibernate.SessionHolder@bc 312f] for key [net.sf.hibernate.impl.SessionFactoryImpl@abbec4] bound to thread [HttpProcessor[8080][1]]
    TransactionSynchronizationManager.java - Retrieved value [org.springframework.orm.hibernate.SessionHolder@bc 312f] for key [net.sf.hibernate.impl.SessionFactoryImpl@abbec4] bound to thread [HttpProcessor[8080][1]]
    TransactionSynchronizationManager.java - Retrieved value [org.springframework.orm.hibernate.SessionHolder@bc 312f] for key [net.sf.hibernate.impl.SessionFactoryImpl@abbec4] bound to thread [HttpProcessor[8080][1]]
    TransactionSynchronizationManager.java - Retrieved value [org.springframework.orm.hibernate.SessionHolder@bc 312f] for key [net.sf.hibernate.impl.SessionFactoryImpl@abbec4] bound to thread [HttpProcessor[8080][1]]
    OpenSessionInViewInterceptor.java - Flushing single Hibernate session in OpenSessionInViewInterceptor
    AbstractBeanFactory.java - Returning cached instance of singleton bean 'welcomeView'
    AbstractMessageSource.java - Creating MessageFormat for pattern [Administracija] and locale 'sl'
    AbstractMessageSource.java - Creating MessageFormat for pattern [Odjava] and locale 'sl'
    TransactionSynchronizationManager.java - Removed value [org.springframework.orm.hibernate.SessionHolder@bc 312f] for key [net.sf.hibernate.impl.SessionFactoryImpl@abbec4] from thread [HttpProcessor[8080][1]]
    OpenSessionInViewInterceptor.java - Closing single Hibernate session in OpenSessionInViewInterceptor
    SessionFactoryUtils.java - Closing Hibernate session
    AbstractApplicationContext.java - Publishing event in context [XmlWebApplicationContext for namespace 'ecos-servlet']: RequestHandledEvent: url=[/ecos/login.htm]; time=[765ms]; client=[127.0.0.1]; method=[POST]; servlet=[ecos]; session=[3090D59C0BD28DEF46E12BFA5BD3E277]; user=[null]; status=[OK]
    AbstractApplicationContext.java - Publishing event in context [Root XmlWebApplicationContext]: RequestHandledEvent: url=[/ecos/login.htm]; time=[765ms]; client=[127.0.0.1]; method=[POST]; servlet=[ecos]; session=[3090D59C0BD28DEF46E12BFA5BD3E277]; user=[null]; status=[OK]
    JobStoreSupport.java - MisfireHandler: scanning for misfires...
    JobStoreSupport.java - Found 0 triggers that missed their scheduled fire-time.
    JobStoreSupport.java - MisfireHandler: scanning for misfires...
    JobStoreSupport.java - Found 0 triggers that missed their scheduled fire-time.
    OpenSessionInViewInterceptor.java - Opening single Hibernate session in OpenSessionInViewInterceptor
    SessionFactoryUtils.java - Opening Hibernate session
    SessionFactoryUtils.java - Registering Spring transaction synchronization for Hibernate session
    TransactionSynchronizationManager.java - Bound value [org.springframework.orm.hibernate.SessionHolder@8a 3a1d] for key [net.sf.hibernate.impl.SessionFactoryImpl@abbec4] to thread [HttpProcessor[8080][1]]
    FrameworkServlet.java - Could not complete request
    java.lang.IllegalStateException: Already a value for key [net.sf.hibernate.impl.SessionFactoryImpl@abbec4] bound to thread

  • #2
    Ales,

    This sequence doesn't look right. Can I ask what version of Spring you're using?

    Is there any chance you can try to build the current Spring from CVS and give it a go? It should be quite stable as we're only a week or so away from 1.1 final.

    Regards,

    Comment


    • #3
      I'm using Spring 1.1rc1.

      I have never tried to build some source from CVS. But if you give me short instructions, I will try to build and test it.

      What about rc2?

      Ales

      Comment


      • #4
        RC2 would be more current than RC1, and better to use all around. I am suggesting to use the CVS version since Juergen has actually done a few fixes in just the last 3-4 days related to session binding and handling. I am not so sure that your issue is related to this, but I would like to avoid any confusion.

        It's actually very easy to pull out Spring and build it, since the build is a standard ant build, and is self contained. Just do an
        ant alljars
        or
        ant release
        The CVS info is here:
        http://sourceforge.net/cvs/?group_id=73357

        However I have actually put up a snapshot from half an hour ago for you, which you can download as:

        http://web2.springframework.com/snap...s-20040823.zip

        Regards,

        Comment


        • #5
          It works.
          Now when I hit F5 to refresh (multiple times) all goes well.
          Really thanx for all.

          Any clue on what was wrong? Why did the session bind at SessionUtils?

          Ales


          //-------------- current log -----------
          Ecos DEBUG [24-08-2004 08:49:55] OpenSessionInViewInterceptor.java - Opening single Hibernate session in OpenSessionInViewInterceptor
          Ecos DEBUG [24-08-2004 08:49:55] SessionFactoryUtils.java - Opening Hibernate session
          Ecos DEBUG [24-08-2004 08:49:55] TransactionSynchronizationManager.java - Bound value [org.springframework.orm.hibernate.SessionHolder@68 e429] for key [net.sf.hibernate.impl.SessionFactoryImpl@b29c9d] to thread [HttpProcessor[8080][3]]
          Ecos DEBUG [24-08-2004 08:49:55] EcosController.java - Searching for user: alesj
          Ecos DEBUG [24-08-2004 08:49:55] TransactionAspectSupport.java - Getting transaction for method 'findUser' in class [com.generalynx.ecos.data.dao.IBasicDAO]
          Ecos DEBUG [24-08-2004 08:49:55] TransactionSynchronizationManager.java - Retrieved value [org.springframework.orm.hibernate.SessionHolder@68 e429] for key [net.sf.hibernate.impl.SessionFactoryImpl@b29c9d] bound to thread [HttpProcessor[8080][3]]
          Ecos DEBUG [24-08-2004 08:49:55] HibernateTransactionManager.java - Found thread-bound session [net.sf.hibernate.impl.SessionImpl@5b4492] for Hibernate transaction
          Ecos DEBUG [24-08-2004 08:49:55] AbstractPlatformTransactionManager.java - Using transaction object [org.springframework.orm.hibernate.HibernateTransac tionObject@f2f0d0]
          Ecos DEBUG [24-08-2004 08:49:55] TransactionSynchronizationManager.java - Initializing transaction synchronization
          Ecos DEBUG [24-08-2004 08:49:55] TransactionSynchronizationManager.java - Retrieved value [org.springframework.orm.hibernate.SessionHolder@68 e429] for key [net.sf.hibernate.impl.SessionFactoryImpl@b29c9d] bound to thread [HttpProcessor[8080][3]]
          Ecos DEBUG [24-08-2004 08:49:55] SessionFactoryUtils.java - Registering Spring transaction synchronization for existing Hibernate session
          Ecos DEBUG [24-08-2004 08:49:55] TransactionSynchronizationManager.java - Retrieved value [org.springframework.orm.hibernate.SessionHolder@68 e429] for key [net.sf.hibernate.impl.SessionFactoryImpl@b29c9d] bound to thread [HttpProcessor[8080][3]]
          Ecos DEBUG [24-08-2004 08:49:55] TransactionSynchronizationManager.java - Retrieved value [org.springframework.orm.hibernate.SessionHolder@68 e429] for key [net.sf.hibernate.impl.SessionFactoryImpl@b29c9d] bound to thread [HttpProcessor[8080][3]]
          Ecos DEBUG [24-08-2004 08:49:55] TransactionAspectSupport.java - Invoking commit for transaction on method 'findUser' in class [com.generalynx.ecos.data.dao.IBasicDAO]
          Ecos DEBUG [24-08-2004 08:49:55] AbstractPlatformTransactionManager.java - Triggering beforeCommit synchronization
          Ecos DEBUG [24-08-2004 08:49:55] SessionFactoryUtils.java - Flushing Hibernate session on transaction synchronization
          Ecos DEBUG [24-08-2004 08:49:55] AbstractPlatformTransactionManager.java - Triggering beforeCompletion synchronization
          Ecos DEBUG [24-08-2004 08:49:55] AbstractPlatformTransactionManager.java - Triggering afterCompletion synchronization
          Ecos DEBUG [24-08-2004 08:49:55] TransactionSynchronizationManager.java - Clearing transaction synchronization
          Ecos DEBUG [24-08-2004 08:49:55] TransactionSynchronizationManager.java - Retrieved value [org.springframework.orm.hibernate.SessionHolder@68 e429] for key [net.sf.hibernate.impl.SessionFactoryImpl@b29c9d] bound to thread [HttpProcessor[8080][3]]
          Ecos DEBUG [24-08-2004 08:49:55] OpenSessionInViewInterceptor.java - Flushing single Hibernate session in OpenSessionInViewInterceptor
          Ecos DEBUG [24-08-2004 08:49:55] TransactionSynchronizationManager.java - Removed value [org.springframework.orm.hibernate.SessionHolder@68 e429] for key [net.sf.hibernate.impl.SessionFactoryImpl@b29c9d] from thread [HttpProcessor[8080][3]]
          Ecos DEBUG [24-08-2004 08:49:55] OpenSessionInViewInterceptor.java - Closing single Hibernate session in OpenSessionInViewInterceptor
          Ecos DEBUG [24-08-2004 08:49:55] SessionFactoryUtils.java - Closing Hibernate session
          Ecos DEBUG [24-08-2004 08:49:55] AbstractApplicationContext.java - Publishing event in context [XmlWebApplicationContext for namespace 'ecos-servlet']: RequestHandledEvent: url=[/ecos/login.htm]; time=[109ms]; client=[127.0.0.1]; method=[POST]; servlet=[ecos]; session=[FE65463532F0DB4F929960323F5C7901]; user=[null]; status=[OK]
          Ecos DEBUG [24-08-2004 08:49:55] AbstractApplicationContext.java - Publishing event in context [Root XmlWebApplicationContext]: RequestHandledEvent: url=[/ecos/login.htm]; time=[109ms]; client=[127.0.0.1]; method=[POST]; servlet=[ecos]; session=[FE65463532F0DB4F929960323F5C7901]; user=[null]; status=[OK]

          Comment

          Working...
          X