I'm using multiple DataSources in my JSF/Spring/Spring-Webflow application. So I tried to declare multiple JpaFlowExecutionListener in the configuration file of Spring Web Flow because i had this problem :
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.abc.commons.domain.Module, no session or session was closed
But this haven't solved the problem. Spring Web Flow appear to use only the first JpaFlowExecutionListener declared in webflow.xml
Any way to solve this problem ?
Thanks in advance
applicationContext.xml
webflow.xmlCode:<jpa:repositories base-package="com.abc.dao.ratikDB" factory-class="com.abc.dao.support.CustomRepositoryFactoryBean" transaction-manager-ref="ratikDBTransactionManager" entity-manager-factory-ref="ratikDBEntityManagerFactory"> </jpa:repositories> <jpa:repositories base-package="com.abc.dao.csmaDB" factory-class="com.abc.dao.support.CustomRepositoryFactoryBean" transaction-manager-ref="csmaDBTransactionManager" entity-manager-factory-ref="csmaDBEntityManagerFactory"> </jpa:repositories> <bean id="ratikDBTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" p:entityManagerFactory-ref="ratikDBEntityManagerFactory"> <description>Please read http://www.springframework.org/docs/reference/transaction.html </description> </bean> <bean id="csmaDBTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" p:entityManagerFactory-ref="csmaDBEntityManagerFactory"> <description>Please read http://www.springframework.org/docs/reference/transaction.html </description> </bean> <bean id="hibernateJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <description>Allow spring to configure hibernate specific settings </description> </bean> <bean id="adminXDBEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" p:dataSource-ref="ratikDBDataSource" p:jpaVendorAdapter-ref="hibernateJpaVendorAdapter" p:jpaProperties="classpath:hibernate.properties"> <description>Build the entity manager with Hibernate as a provider </description> </bean> <bean id="csmaDBEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" p:dataSource-ref="csmaDBDataSource" p:jpaVendorAdapter-ref="hibernateJpaVendorAdapter" p:jpaProperties="classpath:hibernate.properties"> <description>Build the entity manager with Hibernate as a provider </description> </bean>
Code:flow-executor id="flowExecutor"> <flow-execution-listeners> <listener ref="flowTimerFilter" /> <listener ref="facesContextListener" /> <listener ref="securityListener" /> <listener ref="JpaFlowExecutionListener" /> <listener ref="flowsMenuExecutionListener" /> </flow-execution-listeners> <!-- Note1: if you change ' max-executions' then please change also flowsMenuHandler.maxExecutions --> <!-- Note2: when max-execution-snapshots is "0" then snapshoting is disabled, this is better for performances --> <flow-execution-repository max-executions="5" max-execution-snapshots="0"/> </flow-executor> <!-- The registry of executable flow definitions --> <flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF/flows"> <flow-location-pattern value="/**/*-flow.xml" /> </flow-registry> <!-- Configures the Spring Web Flow JSF integration --> <faces:flow-builder-services id="flowBuilderServices" development="true" /> <!-- A listener to create and release a FacesContext --> <beans:bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" /> <!-- A listener to apply Spring Security authorities --> <beans:bean id="securityListener" class="org.springframework.webflow.security.SecurityFlowExecutionListener" /> <beans:bean id="flowTimerFilter" class="com.abc.web.filter.FlowTimerFilter"> <beans:description>Simple debug listener allowing you to track and log the active flow</beans:description> </beans:bean> <beans:bean id="JpaFlowExecutionListener" class="org.springframework.webflow.persistence.JpaFlowExecutionListener"> <beans:constructor-arg ref="ratikDBEntityManagerFactory" /> <beans:constructor-arg ref="ratikDBTransactionManager" /> </beans:bean> <beans:bean id="flowsMenuExecutionListener" class="com.tunisiana.adminx.web.flow.FlowsMenuExecutionListener"> <beans:description>Track the various user's flows so they can be reached from a Menu</beans:description> </beans:bean>



Reply With Quote
