-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Java app on Tomcat return "Network Error (tcp_error)" error
PostPosted: Thu Sep 24, 2009 7:30 am 
Newbie

Joined: Sun Sep 20, 2009 3:09 pm
Posts: 3
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.


Top
 Profile  
 
 Post subject: Re: Java app on Tomcat return "Network Error (tcp_error)" error
PostPosted: Thu Sep 24, 2009 9:01 am 
Newbie

Joined: Sun Aug 16, 2009 8:36 am
Posts: 7
Wotcha Chap,

Sounds very complicated, but, if you are even having problem with 'static' pages then maybe it is an issue with your webserver or your network? I dont think even hibernate has the capability to break a static page not using hibernate!

You need to split your large problem up I think.

#1 : Try getting the webserver working with the static pages reliably.

#2 : Write a separate test case for your hibernate DAO and test it seperately. Profile the test if you think it has some memory leak.


Good luck fella.

Ori


Top
 Profile  
 
 Post subject: Re: Java app on Tomcat return "Network Error (tcp_error)" error
PostPosted: Thu Sep 24, 2009 10:53 am 
Newbie

Joined: Sun Sep 20, 2009 3:09 pm
Posts: 3
Hi Orivar,

Thanks for the reply. What did you mean complicated? Good complicated or bad? Well, I recently started to learn spring with hibernate integration, so I might be doing something wrong!

And the static pages like this:
Code:
   <package name="default" extends="struts-default" namespace="/">
                ..........
      <action name="sitemap" class="com.mypackage.struts.action.SitemapAction">
         <result name="index">/web/content/sitemap/index.jsp</result>
      </action>
                ..........
   </package>


SitemapAction.java is simply
Code:
public class SitemapAction extends ActionSupport {
   public String execute() {
      return "index";
    }
}



Is this supposed to be a problem in this matter too?

Thanks,
Khosrow.


Top
 Profile  
 
 Post subject: Re: Java app on Tomcat return "Network Error (tcp_error)" error
PostPosted: Thu Sep 24, 2009 11:45 am 
Newbie

Joined: Sun Aug 16, 2009 8:36 am
Posts: 7
Hi Chap,

What I mean by 'complicated' is that I think that your issue as it stands might be a bit broad for this forum!

J2EE applications can become very complicated with all the dependencies and technologies involved, so, if you are developing such an applications then you have to learn how to break down an error with respect to its separate components!

You should break up your problem and investigate each piece in turn. Mayerb start by checking you webserver and n/w.

Good luck pal,


Tim

PS: I cannot promise anything but I dont think your error is with Hibernate! So maybe this is not the best place to discuss this problem unless you can isolate it as a hibernate issue.


Top
 Profile  
 
 Post subject: Re: Java app on Tomcat return "Network Error (tcp_error)" error
PostPosted: Wed Jun 05, 2013 12:53 am 
Newbie

Joined: Wed Jun 05, 2013 12:40 am
Posts: 1
I know this post is pretty old, but we came across a similar issue with mod_jk in the recent past and would like to add to the thread.. If you check the Operating Systems "ulimit" values, you may see certain thresholds appear to be quite low especially when you wish to run multiple JBoss nodes on a single machine. We overcame many of these simple limitations by increasing the Thread & Open file values..

Under Linux, these settings are often in "/etc/limits.conf"

    soft limits are simply the currently enforced limits
    hard limits mark the maximum value which cannot be exceeded by setting a soft limit

You could always try doing a "ulimit -n 2048" in order to increase the soft limit within your session. This will only reset the limit for your current shell and the number you specify must not exceed the hard limit.

Once we tweeked the above variables, the system began operating without any difficulties. What really happend was that the JBoss was opening more files than the allowed hard limit (ulimit) would permit for that user. Anyways, we "now" use mod_proxy :-) to handle the load-balancing.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.