Announcement Announcement Module
Collapse
No announcement yet.
OpenSessionInViewFilter +Tiles 2.1.2 = LazyInitializationException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OpenSessionInViewFilter +Tiles 2.1.2 = LazyInitializationException

    hi,
    I'm using spring 2.5.5 with tiles 2.1.2 and hibernate 3.3.1GA

    I'm getting
    Code:
    02:33:54,981  DEBUG org.springframework.orm.hibernate3.support.OpenSessionInViewFilter:181 - Opening single Hibernate Session in OpenSessionInViewFilter
    02:33:54,981  DEBUG org.springframework.orm.hibernate3.support.OpenSessionInViewFilter:181 - Opening single Hibernate Session in OpenSessionInViewFilter
    02:33:54,981  INFO  com.xxx.common.controller.filters.security.SecurityFilter:200 - Applying filter for uri: /yyy/index.htm
    02:33:54,982  DEBUG com.xxx.common.controller.filters.security.SecurityFilter:211 - Stripped uri: /index.htm , is login uri: false
    02:33:58,175  ERROR org.hibernate.LazyInitializationException:42 - failed to lazily initialize a collection of role: com.xxx.yyy.management.model.domain.Ratezone.codes, no session or session was closed
    org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.xxx.yyy.management.model.domain.Ratezone.codes, no session or session was closed
            at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
            at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
            at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
            at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
            at org.hibernate.collection.PersistentBag.toString(PersistentBag.java:506)
            at java.lang.String.valueOf(String.java:2615)
            at java.lang.StringBuilder.append(StringBuilder.java:116)
            at com.xxx.yyy.web.controller.controllers.rate.RateBatchUploadController.referenceData(RateBatchUploadController.java:91)
            at org.springframework.web.servlet.mvc.AbstractFormController.showForm(AbstractFormController.java:574)
            at org.springframework.web.servlet.mvc.SimpleFormController.showForm(SimpleFormController.java:198)
            at org.springframework.web.servlet.mvc.SimpleFormController.showForm(SimpleFormController.java:175)
            at org.springframework.web.servlet.mvc.AbstractFormController.showNewForm(AbstractFormController.java:338)
            at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:278)
            at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
            at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
            at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
            at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
            at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
            at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:114)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)
            at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)
            at com.xxx.common.controller.filters.security.SecurityFilter.doFilterInternal(SecurityFilter.java:331)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
            at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:73)
            at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
            at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:73)
            at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:175)
            at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:240)
            at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:263)
            at com.caucho.server.port.TcpConnection.run(TcpConnection.java:481)
            at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:685)
            at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:607)
            at java.lang.Thread.run(Thread.java:595)
    02:33:58,177  DEBUG org.springframework.orm.hibernate3.support.OpenSessionInViewFilter:207 - Closing single Hibernate Session in OpenSessionInViewFilter
    02:33:58,177  DEBUG org.springframework.orm.hibernate3.support.OpenSessionInViewFilter:207 - Closing single Hibernate Session in OpenSessionInViewFilter
    I'm trying to get a collection in the jsp. In the controller same thing. The service used in the controller has required read only on the get method. As you see it enters in the filter, but I'm curios why it opens twice a single hibernate session ....but any way ...I just want to resolve this problem because a lot of business implementation awaits me.

    so, what's happening ?
    does anyone know how can this be resolved ? thanks.

    regards,
    Viorel
    Last edited by viorel.chelaru; Jun 2nd, 2009, 08:22 PM.

  • #2
    I forgot to mention one little aspect , sorry, I have 2 data sources that I use in the controller, by calling the services. So, I guess OSIVF doesn't work like this.
    But what can I do ? I don't want to load the objects in the services ... in the daos with fetch join.

    please help.

    regards,
    Viorel

    Comment


    • #3
      resolved the problem by adding another OSIVF:
      Code:
      <filter>
      		<filter-name>openSessionInViewFilterOne</filter-name>
      		<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
      		<init-param>
      	      <param-name>sessionFactoryBeanName</param-name>
      	      <param-value>sessionFactory</param-value>
      	    </init-param>
      		<init-param>
      			<param-name>singleSession</param-name>
      			<param-value>true</param-value>
      		</init-param>
      	</filter>
      	
      	<filter>
      		<filter-name>openSessionInViewFilterTwo</filter-name>
      		<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
      		<init-param>
      	      <param-name>sessionFactoryBeanName</param-name>
      	      <param-value>sessionFactory2</param-value>
      	    </init-param>
      		<init-param>
      			<param-name>singleSession</param-name>
      			<param-value>true</param-value>
      		</init-param>
      	</filter>
      
      	<filter-mapping>
      		<filter-name>openSessionInViewFilterOne</filter-name>
      		<url-pattern>/*</url-pattern>
      	</filter-mapping>
      	
      	<filter-mapping>
      		<filter-name>openSessionInViewFilterTwo</filter-name>
      		<url-pattern>/*</url-pattern>
      	</filter-mapping>
      Viorel

      Comment

      Working...
      X