Results 1 to 2 of 2

Thread: openSessionInViewInterceptor - Error migrating to spring 2.5.5

  1. #1
    Join Date
    Jun 2007
    Posts
    5

    Default openSessionInViewInterceptor - Error migrating to spring 2.5.5

    Hi,
    I was using spring 2.1 and had configured the openSessionInViewInterceptor.
    When trying to migrate to spring 2.5.5, and activating the relevant url, I get

    org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
    at org.hibernate.proxy.AbstractLazyInitializer.initia lize(AbstractLazyInitializer.java:60)
    at org.hibernate.proxy.AbstractLazyInitializer.getImp lementation(AbstractLazyInitializer.java:111)
    at org.hibernate.proxy.pojo.javassist.JavassistLazyIn itializer.invoke(JavassistLazyInitializer.java:166 )

    (which was the exception before configuring openSessionInViewInterceptor, and was solved on spring 2.1).
    was there any change in the interceptor mentioned above? any ideas on why this is happening and how to solve it?

    my configuration:

    <bean id="urlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="alwaysUseFullPath" value="true" />
    <property name="interceptors">
    <list>
    <ref bean="openSessionInViewInterceptor"/>
    </list>
    </property>
    <property name="mappings">
    <props>
    <prop key="/providers/*/modules/*/content">getContent</prop>
    </props>
    </property>
    </bean>

    <bean name="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support. OpenSessionInViewInterceptor">
    <property name="sessionFactory">
    <ref bean="hibernateSessionFactory"/>
    </property>
    </bean>

    And the exception:
    org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
    at org.hibernate.proxy.AbstractLazyInitializer.initia lize(AbstractLazyInitializer.java:60)
    at org.hibernate.proxy.AbstractLazyInitializer.getImp lementation(AbstractLazyInitializer.java:111)
    at org.hibernate.proxy.pojo.javassist.JavassistLazyIn itializer.invoke(JavassistLazyInitializer.java:166 )
    ...

    Thanks!
    Last edited by TalN; Jul 16th, 2008 at 03:06 AM.

  2. #2

    Default

    Hi TalN,

    In case you still have this problem.

    I migrated recently some controller to annotation based.

    This is what I have done in the applicationContext configuration file:

    Code:
     <!-- management of annotation based components -->
       <context:component-scan base-package="com.mySite.web" />
       <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
          <property name="interceptors">
             <list>
                <ref bean="openSessionViewInterceptor" />
             </list>
          </property>
       </bean>
    And the bean openSessionViewInterceptor is defined as:

    Code:
     
    
    <bean name="openSessionViewInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
          <property name="sessionFactory" ref="sessionFactory" />
       </bean>
    --
    Davide

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •