Hello there,
I appologize if it's not related, but I've googled about my problem and it seemed that it might be related to Hibernate in some level.
I've recently deployed a java application to an shared Apache / Tomcat server with MySQL as a backend database. It's a UNIX server. Tomcat version is 5.5.
Apache uses mod_jk:
Code:
JkMount /* myAJP
The Application is structured with: Struts2 with Spring and Hibernate integration.
Whenever I try to open a page
1) it takes too long (2-3 minutes!) to open a single page (even the most static ones, I mean even the page which is just a Struts Action execute without anything else)
2) The page stops working with following error appear on the browser screen:
Code:
Network Error (tcp_error)
A communication error occurred: ""
The Web Server may be down, too busy, or experiencing other problems preventing it from
responding to requests. You may wish to try again at a later time.
For assistance, contact your network support team.
Sometimes I've faced to this exception "java.lang.OutOfMemoryError: GC overhead limit exceeded" too.
The frequency of happening of the second thing is something like 90%!
I could only access catalina.out and there were not anything related to the runtime error or exception. In access.log the response code, almost everytime, was 200 but it wasn't corresponded to the browsing situation.
I even tested the site in Lynx as well, which the same thing was occured there as well.
I've searched about the above error and had not come to any resolution except something about Hibernate Leak or cglib.
applicationContext-hibernate.xml
Code:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location"><value>/WEB-INF/jdbc.properties</value></property>
</bean>
<!-- Local DataSource that works in any environment -->
<!-- Note that DriverManagerDataSource does not pool; it is not intended for production -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>${jdbc.driverClassName}</value></property>
<property name="url"><value>${jdbc.url}</value></property>
<property name="username"><value>${jdbc.username}</value></property>
<property name="password"><value>${jdbc.password}</value></property>
</bean>
<!-- JNDI DataSource for J2EE environments -->
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="configLocation">
<value>classpath:my\classpath\domain\hibernate.cfg.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<import resource="/spring-context/spring-hibernate-daos.xml"/>
<import resource="/spring-context/spring-hibernate-services.xml"/>
<import resource="/spring-context/spring-hibernate-actions.xml"/>
</beans>
spring-hibernate-actions.xml
Code:
......
<bean id="FirstAction" class="my.com.package.struts.action.FirstAction">
<property name="firstService"><ref bean="firstService"/></property>
</bean>
<bean id="SecondAction" class="my.com.package.struts.action.SecondAction">
<property name="secondService"><ref bean="secondService"/></property>
</bean>
......
spring-hibernate-services.xml
Code:
......
<bean id="firstService" class="my.com.package.service.FirstServiceImpl">
<property name="firstDAO"><ref bean="firstDAO"/></property>
</bean>
<bean id="secondService" class="my.com.package.service.SecondServiceImpl">
<property name="secondDAO"><ref bean="secondDAO"/></property>
</bean>
......
spring-hibernate-daos.xml
Code:
......
<bean id="firstDAO" class="my.com.package.dao.FirstDAOImpl">
<property name="sessionFactory"><ref bean="sessionFactory"/></property>
</bean>
<bean id="secondDAO" class="my.com.package.dao.SecondDAOImpl">
<property name="sessionFactory"><ref bean="sessionFactory"/></property>
</bean>
......
FirstDAOImpl.java
Code:
package my.com.package.dao;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import my.com.package.domain.First;
public class FirstDAOImpl extends HibernateDaoSupport implements FirstDAO {
public FirstDAOImpl() {}
@Override
public List<First> getContent(String lang) {
List<First> firstContent = this.getHibernateTemplate().find("from First where isDeleted=0");
return firstContent ;
}
}
Is this a correct way? or even an accurate one?
Should I close something that I'm not aware of right now?
I'd really appreciate if anyone could help me find out what's going on!
Regards,
Khosrow.