Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

OpenSessionInViewFilter - lazy loading issue

Avatar

Level 1
I am getting LazyInitializationException when I try to load
lazy data using Hibernate lazy mapping. I have configured
OpenSessionViewInFilter for mxml servlet but it doesn't seem to be
working.

If I use this filter for my custom servlet other than Flex
servlet, lazy loading works fine. Am I missing anything?



Here is my environment.



Backend - Spring Services(exposed as RMI) , Hibernate and SQL
Server- deployed in JBoss as a webapp1.

Frontend - Spring, Flex, FDS, JBoss - deployed as a web app2.

- Assembler class(extends AbstractAssembler) for accessing
spring services from webapp1.



Here is the snippet of code.

web.xml

<filter>

<filter-name>hibernateFilter</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>hibernateFilter</filter-name>

<url-pattern>*.mxml</url-pattern>

</filter-mapping>



data-management-config.xml



<destination id="forms">

<adapter ref="java-dao" />

<properties>

<source>formsAssembler</source>

<factory>spring</factory>

<metadata>

<identity property="formID" type="java.lang.Long"/>

</metadata>

<use-transactions>true</use-transactions>

<cache-items>true</cache-items>

<auto-sync-enabled>true</auto-sync-enabled>

</properties>

</destination>



Assembler:



public class FormsAssembler extends AbstractAssembler

{

FormService formService;



public void setFormService(FormService formService)

{

this.formService = formService;

}



public Collection fill(List fillParameters)

{

return formService.getActiveForms();

}



-- other methods

}











1 Reply

Avatar

Level 1
I suggest that you change the mapping "*.mxml" to
"/*".