PDA

View Full Version : Spring loading Hibernate SessionFactory twice?



vitorsouza
Jan 25th, 2005, 11:17 AM
Hi there,

I'm using Spring for IoC/AOP, WebWork for MVC, Hibernate for persistence with Proxool as connection pool. I'm getting the following exception:


org.logicalcobwebs.proxool.ProxoolException: Attempt to register duplicate pool called 'pool'

I found some posts about Spring x Struts integration that suggested that the problem is the SessionFactory being built twice. But I didn't find anything in my web.xml that could suggest such thing. Here it is:


<web-app>
<display-name>Maven Librarian</display-name>
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>org.springframework.orm.hibernate.support.OpenSess ionInViewFilter</filter-class>
</filter>
<filter>
<filter-name>container</filter-name>
<filter-class>com.opensymphony.webwork.lifecycle.RequestLifecycl eFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>container</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<listener><listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class></listener>
<listener><listener-class>com.opensymphony.xwork.spring.SpringObjectFactoryL istener</listener-class></listener>
<listener><listener-class>com.opensymphony.webwork.lifecycle.ApplicationLife cycleListener</listener-class></listener>
<listener><listener-class>com.opensymphony.webwork.lifecycle.SessionLifecycl eListener</listener-class></listener>
<servlet>
<servlet-name>webwork</servlet-name>
<servlet-class>com.opensymphony.webwork.dispatcher.ServletDispatc her</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>webwork</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
</web-app>


While debugging, I tried deleting all filters and listeners (except Spring's ContextLoaderListener) and the problem continued. So I guess none of them have anything to do with the issue.

Here's my applicationContext.xml:


<beans>
<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFact oryBean">
<property name="configLocation"><value>classpath&#58;/hibernate.cfg.xml</value></property>
</bean>

<bean id="hibernateTransactionManager" class="org.springframework.orm.hibernate.HibernateTransac tionManager">
<property name="sessionFactory"><ref bean="sessionFactory" /></property>
</bean>

<bean id="groupDAO" class="br.com.engenhodesoftware.mavenlibrarian.repository management.persistence.GroupDAOImpl">
<property name="sessionFactory"><ref bean="sessionFactory" /></property>
</bean>

<!-- Other DAOs not shown for brevity... -->

<bean name="appManageGroupsTarget" class="br.com.engenhodesoftware.mavenlibrarian.repository management.application.AppManageGroupsImpl">
<property name="groupDAO"><ref bean="groupDAO" /></property>
</bean>
<bean id="appManageGroups" class="org.springframework.transaction.interceptor.Transa ctionProxyFactoryBean">
<property name="transactionManager"><ref bean="hibernateTransactionManager" /></property>
<property name="target"><ref bean="appManageGroupsTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="create">PROPAGATION_REQUIRED</prop>
<prop key="retrieve">PROPAGATION_REQUIRED</prop>
<prop key="update">PROPAGATION_REQUIRED</prop>
<prop key="delete">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>

<!-- Other App classes not shown for brevity... -->

<bean name="manageGroupsAction" class="br.com.engenhodesoftware.mavenlibrarian.repository management.view.xwork.ManageGroupsAction" singleton="false">
<property name="appManageGroups"><ref bean="appManageGroups" /></property>
</bean>

<!-- Other XWork actions not shown for brevity... -->
</beans>


Any ideas, please?

Thanks in advance,

Vítor Souza

dthompson
Aug 19th, 2005, 12:21 PM
I have the same issue when using Spring, JSF and ACEGI. Tracing the code through the debugger indicates that the ACEGI daoAuthenticationProvider bean is creating my sessionFactory bean twice.


Regards,

Dave Thompson