Hi,
I have a web application powered by struts 2-Spring-hibernate. It is working fine in all screens. After some time, when I press submit button to fetch the results, hibernate hangs while opening a connection. It hangs for hours. no error messages are written in the log.
LOG:
------
Code:
16:58:14,144 DEBUG SessionFactoryUtils:316 - Opening Hibernate Session
16:58:14,144 DEBUG SessionImpl:220 - opened session at timestamp: 12670306941
16:58:14,144 DEBUG BaseDAO:60 - getting list from crit
16:58:14,144 DEBUG AbstractBatcher:366 - about to open PreparedStatement (open PreparedStatements: 0, globally: 1)
16:58:14,159 DEBUG ConnectionManager:421 - opening JDBC connection
SPRING BEAN CONFIGURATION
------------------------------
Code:
<!-- DAO BEANS -->
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/license_dev" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<bean id="myHibernateProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.query.substitutions">true 'T', false 'F'</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.c3p0.minPoolSize">5</prop>
<prop key="hibernate.c3p0.maxPoolSize">20</prop>
<prop key="hibernate.c3p0.timeout">600</prop>
<prop key="hibernate.c3p0.max_statement">50</prop>
<prop key="hibernate.c3p0.testConnectionOnCheckout">false</prop>
</props>
</property>
</bean>
<bean id="mySessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="myDataSource" />
</property>
<property name="hibernateProperties">
<ref bean="myHibernateProperties" />
</property>
<!-- OR mapping files. -->
<property name="mappingResources">
<list>
<value>entity.hbm.xml</value>
</list>
</property>
</bean>
<bean id="baseDAO" class="com.eginnovations.license.dao.BaseDAO"
autowire="byType">
<property name="dataSource" ref="myDataSource" />
<property name="sessionFactory" ref="mySessionFactory" />
</bean>
BASE DAO CLASS
----------------
Code:
package com.eginnovations.license.dao;
import java.util.List;
import javax.sql.DataSource;
import org.apache.log4j.Logger;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.transaction.annotation.Transactional;
public class BaseDAO extends HibernateDaoSupport implements IBaseDAO {
protected Logger logger = Logger.getLogger(BaseDAO.class);
protected DataSource dataSource;
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
@Transactional
public void save(Object entity){
logger.info("Saving object:"+entity);
super.getHibernateTemplate().save(entity);
logger.info("Object save successful:"+entity);
}
@SuppressWarnings("unchecked")
@Transactional
public List<Object> list(String qry) {
return (List<Object>) super.getHibernateTemplate().find(qry);
}
@SuppressWarnings("unchecked")
@Transactional
public List<Object> list(String qry, Object[] object) {
return (List<Object>) super.getHibernateTemplate().find(qry, object);
}
}
Any help will be appreciated.
Thanks