Announcement Announcement Module
Collapse
No announcement yet.
Yet Another LazyInitializationException with OpenSessionInViewFilter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Yet Another LazyInitializationException with OpenSessionInViewFilter

    I know there have been 100s of posts regarding this issues, but none of them seems to help me. I am very new to Spring, this is my first project I am doing using it. I am attempting to do lazy loading in my application, but I am getting the infamous: 'org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role:' I am attempting to use Spring with JSF2 (Mojarra 2.1.13) but I can't seem to figure out what I am doing wrong. I am going to break my post up due to the 10,000 character limit.

    web.xml
    ============

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
        <context-param>
            <param-name>javax.faces.PROJECT_STAGE</param-name>
            <param-value>Development</param-value>
        </context-param>
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/application-context.xml</param-value>
        </context-param>    
        <context-param>
            <param-name>primefaces.THEME</param-name>
            <param-value>home</param-value>
        </context-param>
        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.html</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                60
            </session-timeout>
        </session-config>
        
        
        <!-- Listeners - Spring should come first because we need them for our listener -->
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        <listener>
            <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
        </listener>
        <listener>
            <listener-class>net.dupage88.www.servlet.SiteServletContextListener</listener-class>
        </listener>
        
        <welcome-file-list>
            <welcome-file>index.html</welcome-file>
        </welcome-file-list>
        <error-page>
            <exception-type>javax.faces.application.ViewExpiredException</exception-type>
            <location>/public/index.html</location>
        </error-page>
        
        <!-- For Lazy Loading -->
        <filter>
            <filter-name>hibernateFilter</filter-name>
            <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
        </filter> 
        <filter-mapping> 
            <filter-name>hibernateFilter</filter-name> 
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        
        <filter>
            <filter-name>RootRedirectFilter</filter-name>
            <filter-class>net.dupage88.www.filters.RootRedirectFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>RootRedirectFilter</filter-name>
            <url-pattern>/index.html</url-pattern>
        </filter-mapping>
    
        <filter>
            <filter-name>ShiroFilter</filter-name>
            <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>ShiroFilter</filter-name>
            <url-pattern>/*</url-pattern>
            <dispatcher>REQUEST</dispatcher>
            <dispatcher>FORWARD</dispatcher>
            <dispatcher>INCLUDE</dispatcher>
            <dispatcher>ERROR</dispatcher>
        </filter-mapping>
        
        <listener>
            <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
        </listener>
        
        <filter>
            <filter-name>PrimeFaces FileUpload Filter</filter-name>
            <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
        </filter>	
        <filter-mapping>
            <filter-name>PrimeFaces FileUpload Filter</filter-name>
            <servlet-name>Faces Servlet</servlet-name>
        </filter-mapping>
    </web-app>

  • #2
    application-context.xml
    =================

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:aop="http://www.springframework.org/schema/aop" 
           xmlns:tx="http://www.springframework.org/schema/tx" 
           xsi:schemaLocation="http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
            http://www.springframework.org/schema/context 
    	http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.springframework.org/schema/tx 
            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
            http://www.springframework.org/schema/aop 
            http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
        
        <context:annotation-config />
        <context:component-scan base-package="com.cwssoft.dbmanager"/>
        <context:component-scan base-package="net.dupage88.www"/>
        
        <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
            <property name="scopes">
                <map>
                    <entry key="view">
                        <bean class="net.dupage88.www.spring.scope.ViewScope"/>
                    </entry>
                </map>
            </property>
        </bean>
    
        
        <!-- ORM Stuff -->
        <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiName" value="java:comp/env/jdbc/www" />
        </bean>
        
        <!-- use spring hibernate transaction manager with AOP -->
        <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory" ref="sessionFactory" />
        </bean>
        
        <!-- for @Transactional -->
        <tx:annotation-driven transaction-manager="txManager" />
        
        <!-- We leave the model/domain objects in the hibernate.cfg.xml as well so we can output the DDL to a text file -->
        <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
            <property name="dataSource" ref="dataSource"/>
            <property name="configLocation">
                <value>
                    classpath:/hibernate.cfg.xml
                </value>
            </property>
            <property name="annotatedClasses">
                <list>
                    <value>com.cwssoft.dbmanager.settings.Setting</value>
                    <value>net.dupage88.www.model.GeneralProperty</value>
                    <value>net.dupage88.www.model.site.Site</value>
                    <value>net.dupage88.www.model.resources.Script</value>
                    <value>net.dupage88.www.model.resources.Style</value>
                    <value>net.dupage88.www.model.resources.Header</value>
                    <value>net.dupage88.www.model.resources.VanityUrl</value>
                    <value>net.dupage88.www.model.adminmenu.AdminMenuItem</value>
                </list>
            </property>
        </bean>
        <!-- End ORM Stuff -->
        
        
        
        <!-- ===============================
                          All DAOs 
             =============================== -->
            
            <!-- This is the setting bean that we use to store all the system settings -->
            <bean id="settingsDao" class="com.cwssoft.dbmanager.settings.SettingsDaoOrm">
                <constructor-arg value="com.cwssoft.dbmanager.settings.Setting" />
                <property name="sessionFactory" ref="sessionFactory" />
            </bean>
    
            <!-- Site DAO -->
            <bean class="net.dupage88.www.dao.DefaultSiteDao" id="siteDao">
                <constructor-arg value="net.dupage88.www.model.site.Site" />
                <property name="sessionFactory" ref="sessionFactory" />
            </bean>
            
            <!-- Admin Menu Item DAO -->
            <bean class="net.dupage88.www.dao.DefaultAdminMenuItemDao" id="adminMenuItemDao">
                <constructor-arg value="net.dupage88.www.model.adminmenu.AdminMenuItem" />
                <property name="sessionFactory" ref="sessionFactory" />
            </bean>
            
            <!-- Vanity URL Item DAO -->
            <bean class="com.cwssoft.dbmanager.dao.GenericDaoOrm" id="vanityUrlDao">
                <constructor-arg value="net.dupage88.www.model.resources.VanityUrl" />
                <property name="sessionFactory" ref="sessionFactory" />
                <property name="defaultOrderBy" value="target" />
            </bean>
            
            <!-- Header DAO -->
            <bean class="com.cwssoft.dbmanager.dao.GenericDaoOrm" id="headerDao">
                <constructor-arg value="net.dupage88.www.model.resources.Header" />
                <property name="sessionFactory" ref="sessionFactory" />
                <property name="defaultOrderBy" value="name" />
            </bean>
            
            <!-- Script DAO -->
            <bean class="com.cwssoft.dbmanager.dao.GenericDaoOrm" id="scriptDao">
                <constructor-arg value="net.dupage88.www.model.resources.Script" />
                <property name="sessionFactory" ref="sessionFactory" />
                <property name="defaultOrderBy" value="priority" />
            </bean>
            
            <!-- Style DAO -->
            <bean class="com.cwssoft.dbmanager.dao.GenericDaoOrm" id="styleDao">
                <constructor-arg value="net.dupage88.www.model.resources.Style" />
                <property name="sessionFactory" ref="sessionFactory" />
                <property name="defaultOrderBy" value="priority" />
            </bean>
            
        <!-- End DAOs -->
        
        
        <!-- ===============================
                      All Services 
             =============================== -->
        
            <!-- This is the bean that manages the database schema/DDL -->
            <bean class="com.cwssoft.dbmanager.ddl.GeneralDatabaseManager" id="databaseInstaller">
                <property name="settingsDao" ref="settingsDao" />
                <property name="packages">
                    <list>
                        <bean class="net.dupage88.www.db.packages.ToVersion1">
                            <property name="sessionFactory" ref="sessionFactory" />
                            <property name="settingsDao" ref="settingsDao" />
                        </bean>
                    </list>
                </property>
            </bean>
            
            <!-- Site Service -->
            <bean class="net.dupage88.www.service.DefaultSiteService" id="siteService">
                <property name="dao" ref="siteDao" />
            </bean>
          
        <!-- End Services -->
        
        <!-- ===============================
                      All Beans 
              =============================== -->
              
            <!-- Site Bean -->
            <bean class="net.dupage88.www.beans.admin.SiteBean" id="siteBean">
                <property name="crudService" ref="siteService" />
            </bean>
     
            
            <!-- Header Bean -->
            <bean class="net.dupage88.www.beans.admin.HeaderBean" id="headerBean">
                <property name="crudService" ref="headerService" />
            </bean>
            
            <!-- Script Bean -->
            <bean class="net.dupage88.www.beans.admin.ScriptBean" id="scriptBean">
                <property name="crudService" ref="scriptService" />
            </bean>
            
     
        <!-- End Beans -->    
        
        <!-- ===============================
                  All Converters (Beans)
              =============================== -->                
              
            <!-- Header Converter -->
            <bean class="net.dupage88.www.model.converters.DefaultConverter" id="headerConverter">
                <property name="service" ref="headerService" />
            </bean>          
            
            <!-- Header Converter -->
            <bean class="net.dupage88.www.model.converters.DefaultConverter" id="scriptConverter">
                <property name="service" ref="scriptService" />
            </bean>    
    </beans>

    Comment


    • #3
      Here is the segment my view that is causing the issue...

      Code:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:p="http://primefaces.org/ui" 
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:d="http://java.sun.com/jsf/composite/components">
      <body>
          <ui:composition>
              <p:tabView style="width: 600px;" orientation="left">
                  <p:tab title="#{text['general.general']}">
                      <ui:include src="/WEB-INF/view/admin/dialogs/site.xhtml" />
                  </p:tab>
                  <p:tab title="#{text['admin.sites.editdlg.tab.headers.title']}">
                     <h:panelGrid styleClass="two-col" columns="2" style="width: 400px;">
                         <h:outputText value="#{text['admin.sites.editdlg.tab.headers.header']}" />
                         <h:selectOneMenu converter="#{headerConverter}" value="#{siteBean.workingItem.header}">
                              <f:selectItem itemLabel="#{text['general.selectone']}" itemValue="#{null}" noSelectionOption="true" />
                              <!-- <f:selectItems value="{headerBean.allItems}" var="item" itemLabel="{item.name}" itemValue="{item}"/>  -->
                         </h:selectOneMenu>
                     </h:panelGrid>
                  </p:tab>
                  <p:tab title="#{text['admin.sites.editdlg.tab.script.title']}">
                      <h:panelGrid styleClass="two-col" columns="2" style="width: 400px;">
                          <h:outputText value="#{text['admin.sites.editdlg.tab.script.scripts']}" />
                          <p:selectManyCheckbox converter="#{scriptConverter}" value="#{siteBean.workingItem.scripts}">  
                              <!--<f:selectItems value="{scriptBean.allItems}" />-->
                          </p:selectManyCheckbox>
                      </h:panelGrid>
                  </p:tab>
                  <p:tab title="#{text['admin.sites.editdlg.tab.style.title']}">
                  </p:tab>
                  <p:tab title="#{text['admin.sites.editdlg.tab.props.title']}">
                  </p:tab>
              </p:tabView>
          </ui:composition>
      </body>
      </html>
      The portion of my view that is causing the exception is:

      <p:selectManyCheckbox converter="#{scriptConverter}" value="#{siteBean.workingItem.scripts}">

      The above file in loaded using (via ajax) by clicking on the site from the following composite component.

      Code:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:composite="http://java.sun.com/jsf/composite"
            xmlns:p="http://primefaces.org/ui" 
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core">
      
          <!-- INTERFACE -->
          <composite:interface>
              <composite:attribute name="crudBean" type="net.dupage88.www.beans.CrudBean" required="true" />
              <composite:attribute name="tableStyle" type="java.lang.String" required="false" default="default-datatable" />
              <composite:attribute name="renderAddButton" type="java.lang.Boolean" required="false" default="#{false}" />
              <composite:attribute name="renderActionButtons" type="java.lang.Boolean" required="false" default="#{false}" />
          </composite:interface>
          
          <!-- IMPLEMENTATION -->
          <composite:implementation>
              <p:outputPanel autoUpdate="true">
                  <p:dataTable 
                      rows="20" 
                      emptyMessage="#{text['general.table.empty']}" 
                      filteredValue="#{cc.attrs.crudBean.filteredList}" 
                      paginatorAlwaysVisible="false" 
                      var="item" 
                      value="#{cc.attrs.crudBean.allItems}"  
                      tableStyleClass="#{cc.attrs.tableStyle}">
                      <f:facet name="header" >
                          <p:commandButton action="#{cc.attrs.crudBean.createWorkingItem}" oncomplete="addDialog.show();" rendered="#{cc.attrs.renderAddButton}" icon="ui-icon-circle-plus" />
                      </f:facet>
                      <composite:insertChildren />
                      
                      <p:column>
                          <f:facet name="header">
                              <h:outputText value="#{text['admin.general.listing.actions']}" />
                          </f:facet>
                          <p:commandLink oncomplete="editDialog.show();" styleClass="small-icon">
                              <f:setPropertyActionListener target="#{cc.attrs.crudBean.workingItem}" value="#{item}" />
                              <p:graphicImage url="/public/images/agora/edit.png" />
                          </p:commandLink>
                          <p:spacer width="10" height="1" />
                          <p:commandLink oncomplete="deleteDialog.show();" styleClass="small-icon">
                              <f:setPropertyActionListener target="#{cc.attrs.crudBean.workingItem}" value="#{item}" />
                              <p:graphicImage url="/public/images/agora/remove.png" />
                          </p:commandLink>
                      </p:column>
                  </p:dataTable>
              </p:outputPanel>
          </composite:implementation>
      </html>
      My scripts lists is define as follows:
      Code:
          @ManyToMany
          @BatchSize(size=5)
          @OrderBy("priority ASC")
          private List<Script> scripts;

      Comment


      • #4
        Here is the exception and trace:

        Code:
        05 Nov 2012 12:42:03,918 ERROR LazyInitializationException:19 - failed to lazily initialize a collection of role: net.dupage88.www.model.site.Site.scripts, no session or session was closed
        org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net.dupage88.www.model.site.Site.scripts, no session or session was closed
        	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
        	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
        	at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
        	at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
        	at org.hibernate.collection.PersistentBag.toArray(PersistentBag.java:257)
        	at org.primefaces.renderkit.SelectManyRenderer.getValues(SelectManyRenderer.java:55)
        	at org.primefaces.component.selectmanycheckbox.SelectManyCheckboxRenderer.encodeSelectItems(SelectManyCheckboxRenderer.java:142)
        	at org.primefaces.component.selectmanycheckbox.SelectManyCheckboxRenderer.encodeMarkup(SelectManyCheckboxRenderer.java:60)
        	at org.primefaces.component.selectmanycheckbox.SelectManyCheckboxRenderer.encodeEnd(SelectManyCheckboxRenderer.java:43)
        	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
        	at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)
        	at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
        	at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
        	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
        	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
        	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
        	at org.primefaces.component.tabview.TabViewRenderer.encodeTabContent(TabViewRenderer.java:280)
        	at org.primefaces.component.tabview.TabViewRenderer.encodeContents(TabViewRenderer.java:238)
        	at org.primefaces.component.tabview.TabViewRenderer.encodeMarkup(TabViewRenderer.java:128)
        	at org.primefaces.component.tabview.TabViewRenderer.encodeEnd(TabViewRenderer.java:69)
        	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
        	at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:59)
        	at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:43)
        	at org.primefaces.component.outputpanel.OutputPanelRenderer.encodeEnd(OutputPanelRenderer.java:46)
        	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
        	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
        	at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
        	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
        	at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:55)
        	at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:43)
        	at org.primefaces.component.dialog.DialogRenderer.encodeEnd(DialogRenderer.java:38)
        	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
        	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
        	at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:519)
        	at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
        	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1612)
        	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
        	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
        	at javax.faces.component.UINamingContainer.visitTree(UINamingContainer.java:163)
        	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
        	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
        	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
        	at javax.faces.component.UINamingContainer.visitTree(UINamingContainer.java:163)
        	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
        	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
        	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
        	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
        	at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:377)
        	at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:297)
        	at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183)
        	at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:981)
        	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
        	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:409)
        	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
        	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
        	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
        	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        	at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
        	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
        	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
        	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
        	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
        	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
        	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
        	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
        	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
        	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118)
        	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
        	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
        	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
        	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
        	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
        	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
        	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
        	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        	at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
        	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
        	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
        	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
        	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
        	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
        	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
        	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
        	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
        	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
        	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        	at java.lang.Thread.run(Thread.java:722)
        Any pointers would REALLY be appreciated as I am kind of lost. So thanks in advance!

        Chuck Syperski

        Comment


        • #5
          And how would you expect the OpenSessionInView filter would help... Basically it is OpenSessionDuringRequest (view is misleading here) as soon as your request is over the session is closed and t he same goes for new requests (like your ajax request) those aren't using the same session (session/transaction is thread bound, each request is handled by a different thread).

          So for JSF (or Spring Web Flow) this isn't going to work.

          Comment


          • #6
            OK, you might not like my pointer.

            In my opinion, and many others, just not everyone

            1) Open Session In View is an Anti-Pattern.

            Here's why, you probably already knew that in that page you needed the scripts in Site.scripts, but you didn't retreive them in your use case. Instead you were ok to increase the amount of calls back and forth to the database, and tried to lazy load them. So you probably decreased your performance for that use case.

            So what do you do? 1) You do NOT set the scripts property to eager fetch in your mapping.

            What you do is you write your Use case logic/query to eager fetch the scripts in the query for the Site object(s).

            How does that look.

            In HQL that would be something like

            "FROM Site s JOIN FETCH s.scripts"

            That will load all the Site objects with their scripts collections fully populated.

            That calls the database only once and loads all the data you need for your JSF page, nothing more, nothing less.

            Good Luck

            Mark

            Comment

            Working...
            X