Announcement Announcement Module
Collapse
No announcement yet.
OpenSessionInViewFilter closing Sessions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OpenSessionInViewFilter closing Sessions

    I'm using the CVS build of Spring 1.1.5. I was using OpenSessionInViewInterceptor, but now I'm trying to integrate ACEGI and so I need to session opened before the ACEGI filters run, which means I need to put an OpenSessionInView filter before my ACEGI filter, right? Anyway, now everything is randomly breaking. Sometimes a page will load, then I hit reload and I get a lazy initialize error. ACEGI is not cachign anything across requests, and neither am I. Every time I track the exception to the code it's in an object that was just taking out of Hibernate. Here's my web.xml:

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
       PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
       "http&#58;//java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    
    <context-param>
     <param-name>contextConfigLocation</param-name>
     <param-value>
      /WEB-INF/eha-servlet.xml
     </param-value>
    </context-param>
    
    <filter>
      <filter-name>osivFilter</filter-name>
      <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
      <init-param>
        <param-name>singleSession</param-name>
        <param-value>true</param-value>
      </init-param>
    </filter>
    
    <filter-mapping>
     <filter-name>osivFilter</filter-name>
     <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <filter>
         <filter-name>Acegi Filter Chain Proxy</filter-name>
         <filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class>
         <init-param>
             <param-name>targetClass</param-name>
             <param-value>net.sf.acegisecurity.util.FilterChainProxy</param-value>
         </init-param>
    </filter>
    
    <filter-mapping>
        <filter-name>Acegi Filter Chain Proxy</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <listener>
     	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    
    <filter>
     <filter-name>allPages</filter-name>
     <filter-class>eha.filter.SiteFilter</filter-class>
    </filter>
    
    <filter-mapping>
     <filter-name>allPages</filter-name>
     <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <servlet>
     <servlet-name>eha</servlet-name>
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
     <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
     <servlet-name>eha</servlet-name>
     <url-pattern>*.html</url-pattern>
    </servlet-mapping>
    
    </web-app>
    Here's the stack trace. As you can see, the view should be open:

    Code:
    org.hibernate.LazyInitializationException&#58; could not initialize proxy - the owning Session was closed
    	org.hibernate.proxy.AbstractLazyInitializer.initialize&#40;AbstractLazyInitializer.java&#58;53&#41;
    	org.hibernate.proxy.AbstractLazyInitializer.getImplementation&#40;AbstractLazyInitializer.java&#58;80&#41;
    	org.hibernate.proxy.CGLIBLazyInitializer.intercept&#40;CGLIBLazyInitializer.java&#58;133&#41;
    	eha.dao.EzMemb$$EnhancerByCGLIB$$e680b14e.toString&#40;<generated>&#41;
    	java.lang.String.valueOf&#40;String.java&#58;2577&#41;
    	java.util.AbstractCollection.toString&#40;AbstractCollection.java&#58;454&#41;
    	java.lang.String.valueOf&#40;String.java&#58;2577&#41;
    	java.lang.StringBuffer.append&#40;StringBuffer.java&#58;220&#41;
    	java.util.AbstractMap.toString&#40;AbstractMap.java&#58;598&#41;
    	java.lang.String.valueOf&#40;String.java&#58;2577&#41;
    	java.lang.StringBuffer.append&#40;StringBuffer.java&#58;220&#41;
    	org.springframework.web.servlet.view.AbstractView.render&#40;AbstractView.java&#58;234&#41;
    	org.springframework.web.servlet.DispatcherServlet.render&#40;DispatcherServlet.java&#58;917&#41;
    	org.springframework.web.servlet.DispatcherServlet.doDispatch&#40;DispatcherServlet.java&#58;696&#41;
    	org.springframework.web.servlet.DispatcherServlet.doService&#40;DispatcherServlet.java&#58;623&#41;
    	org.springframework.web.servlet.FrameworkServlet.serviceWrapper&#40;FrameworkServlet.java&#58;384&#41;
    	org.springframework.web.servlet.FrameworkServlet.doGet&#40;FrameworkServlet.java&#58;344&#41;
    	javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;689&#41;
    	javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;802&#41;
    	eha.filter.SiteFilter.doFilter&#40;SiteFilter.java&#58;116&#41;
    	net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter&#40;FilterChainProxy.java&#58;300&#41;
    	net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke&#40;FilterSecurityInterceptor.java&#58;84&#41;
    	net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter.doFilter&#40;SecurityEnforcementFilter.java&#58;181&#41;
    	net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter&#40;FilterChainProxy.java&#58;311&#41;
    	net.sf.acegisecurity.ui.AbstractProcessingFilter.doFilter&#40;AbstractProcessingFilter.java&#58;372&#41;
    	net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter&#40;FilterChainProxy.java&#58;311&#41;
    	net.sf.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter&#40;HttpSessionContextIntegrationFilter.java&#58;217&#41;
    	net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter&#40;FilterChainProxy.java&#58;311&#41;
    	net.sf.acegisecurity.util.FilterChainProxy.doFilter&#40;FilterChainProxy.java&#58;179&#41;
    	net.sf.acegisecurity.util.FilterToBeanProxy.doFilter&#40;FilterToBeanProxy.java&#58;125&#41;
    	org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal&#40;OpenSessionInViewFilter.java&#58;172&#41;
    	org.springframework.web.filter.OncePerRequestFilter.doFilter&#40;OncePerRequestFilter.java&#58;76&#41;
    Does anyone have any ideas about this? I'll really owe you one. This has been driving my nuts for days. Thanks!

    [EDIT] Switched back from Hibernate3 and Spring 1.2 to see if it was a bug in the new version... it's not.

  • #2
    Could it be you've defined a proxy=... in your hibernate class ? Try to leave that out. Please post the hibernate mapping config of EzMemb.

    Comment


    • #3
      Here's the mapping file in its entirety because I'm not sure I understand what your looking for.

      Code:
      <?xml version="1.0"?>
      <!DOCTYPE hibernate-mapping PUBLIC
              "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
              "http&#58;//hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
      
      <hibernate-mapping>
      
              <class name="eha.dao.EzMemb" table="EHA.ezMemb" mutable="false">
              		<cache usage="read-only" />
                      <id name="membid" type="string">
                              <generator class="assigned"/>
                      </id>
                      <property name="subssn"/>
                      <component name="name" class="eha.dao.Name">
      	                <property name="lastnm"/>
      	                <property name="firstnm"/>
      	                <property name="mi"/>
      	            </component>
                      <property name="patid"/>
                      <property name="sex"/>
                      <component name="address" class="eha.dao.Address">
                      	<property name="street"/>
                      	<property name="city"/>
                      	<many-to-one name="state" column="state" outer-join="true"/>
                      	<property name="zip"/>
                     	</component>
                      <property name="phone"/>
                      <property name="birth" type="date"/>
                      <property name="hpCode"/>
                      <set name="claims" sort="natural" lazy="true">
                      	<cache usage="read-write"/>
                      	<key column="membid"/>
                      	<one-to-many class="eha.dao.Claim"/>
                      </set>
                      <set name="providerHistory" sort="natural" lazy="true">
                      	<cache usage="read-write"/>
                      	<key column="membid"/>
                      	<one-to-many class="eha.dao.EzMembPcp"/>
                      </set>
                      <set name="healthPlans" sort="natural" lazy="true">
                      	<cache usage="read-write"/>
      					<key column="membid"/>
      					<one-to-many class="eha.dao.EzMembHp"/>
      				</set>
              </class>
      
      </hibernate-mapping>

      Comment


      • #4
        Try without caching and without mutable=false to pinpoint the problem.

        Cheers, Stefaan.

        Comment


        • #5
          Can you show the toString method? Most likely you are using one of the lazy-init collections from the entity definitions which break on a different request as the session is closed.

          Comment

          Working...
          X