-->
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.  [ 1 post ] 
Author Message
 Post subject: Software caused connection abort: recv failed (Please Help)
PostPosted: Tue Mar 01, 2005 7:58 pm 
Newbie

Joined: Fri Feb 25, 2005 5:31 pm
Posts: 1


Hi All,
I've searched the forum and I've googled just about as much as I possibly could before troubling anyone for thier help on this issue.
I've even pulled in our expert java guy and we both cannot seem to figure out what is causing this issue. For the most part my application runs good. If I just run the the application off a freash startup of Netbeans 4.0 running Tomcat 5.0.28 then I get the error that is in the Subject
Quote:
Software caused connection abort: recv failed
. The wierd part is, my application works perfectly fine at this point. The real issue is that after It sits for a while, my application times out like it's suposed to and that is when I am unable to connect or reconnect and I get an SQLException occurd error. It's buital I can even log out of my app and then relogin and my app just doesn't work.


Anyone can download my application at:
Http://mypc.ipupdater.com/jotpm.zip

You need two Libraries in Netbeans for my application to work one for
Quote:
Stuts
Quote:
Hibernate


In netbeans If you right click on the project and go to properties you can see the compiling sources. ( I felt compelled to tell you this, even though your helping me and probably already knew that *smiles*)



Hibernate version:
version 2.1.6, 9.8.2004

Mapping documents:
I have 5 mapping documents.
1. hibernate.cfg.xml
Code:
<!DOCTYPE hibernate-configuration PUBLIC
   "-//Hibernate/Hibernate Configuration DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
    <session-factory>

        <!-- This is the datasource connection you have setup in the Admin -->
        <!-- <property name="connection.datasource">java:/jdbc/test</property> -->
        <!--- <property name="connection.driver_class">com.mysql.jdbc.Driver</property> -->
        <property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
        <property name="connection.username">root</property>
        <property name="connection.password">gizmos44</property>
        <property name="connection.url">jdbc:mysql://mypc.ipupdater.com:3306/jotpm</property>
        <property name="hibernate.c3p0.min_size">1</property>
        <property name="hibernate.c3p0.max_size">10</property>
        <property name="hibernate.c3p0.timeout">300</property>
        <property name="hibernate.c3p0.max_statements">50</property>
        <property name="hibernate.c3p0.idle_test_period">3000</property>
        <property name="hibernate.c3p0.validate">true</property>

       
        <property name="show_sql">true</property>
        <!-- You can Get the dialect from the hibernate.properties file. -->
        <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

        <!-- Example HowTo: Mapping files -->
        <mapping resource="socalgas/model/User.hbm.xml"/>
        <mapping resource="socalgas/model/Project.hbm.xml"/>
        <mapping resource="socalgas/model/Milestone.hbm.xml"/>
        <mapping resource="socalgas/model/Status.hbm.xml"/>

    </session-factory>       
</hibernate-configuration>


2. User.hbm.xml
Code:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
                       
<hibernate-mapping package="socalgas.model">

<class name="Milestone"
      table="tbl_milestones"
      lazy="true">

   <id name="id"
      type="long"
      column="fld_milestone_id"
      unsaved-value="null">
      <generator class="native"/>
   </id>

   <property   name="description"
                    type="string"
                    column="fld_milestone_desc"
                    not-null="true"/>

   <property   name="creationDate"
                    type="java.util.Date"
                    column="fld_milestone_creation_date"
                    not-null="true"/>
                               
        <many-to-one name="project"
                     class="Project"
                     column="fld_milestone_project_id"
                     cascade="save-update" />

        <many-to-one name="status"
                     class="Status"
                     column="fld_milestone_status_id"
                     cascade="save-update" />
</class>

</hibernate-mapping>


3. Project.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
                       
<hibernate-mapping package="socalgas.model">

<class name="Project"
      table="tbl_projects"
      lazy="false">

   <id name="id"
      type="long"
      column="fld_project_id"
      unsaved-value="null">
      <generator class="native"/>
   </id>

           <!-- We don't change the username, so map it with update="false".
       This is an immutable property, it is also unique. -->
                 
   <property   name="name"
                    type="string"
                    column="fld_project_name"
                    length="255"
                    not-null="true" />

   <property   name="description"
                    type="string"
                    column="fld_project_desc"
                    not-null="true"/>

   <property   name="creationDate"
                    type="java.util.Date"
                    column="fld_project_creation_date"
                    not-null="true"/>

   <property   name="completionDate"
                    type="java.util.Date"
                    column="fld_project_completion_date"
                    not-null="true"/>
                               
        <many-to-one name="manager"
                     class="User"
                     column="fld_project_manager_id"
                     cascade="save-update" />

        <many-to-one name="status"
                     class="Status"
                     column="fld_project_status_id"
                     cascade="save-update" />

        <list name="milestones" table="tbl_milestones" lazy="true">
            <key column="fld_milestone_project_id" />
            <index column="fld_milestone_id" />
            <one-to-many class="Milestone"/>
        </list>
       
       
<!--                     
        <set name="milestones" table="tbl_milestones">
            <key column="fld_milestone_project_id" />
            <one-to-many class="Milestone"/>
        </set>
-->
                                                   
</class>

</hibernate-mapping>

4. Status.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
                       
<hibernate-mapping package="socalgas.model">

<class name="Status"
      table="tbl_status"
      lazy="false">

   <id name="id"
      type="long"
      column="fld_status_id"
      unsaved-value="null">
      <generator class="native"/>
   </id>

           <!-- We don't change the username, so map it with update="false".
       This is an immutable property, it is also unique. -->
                 
   <property  name="description"
            type="string"
            column="fld_status_desc"
            length="255"
       not-null="true" />
</class>

</hibernate-mapping>

5. Milestone.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
                       
<hibernate-mapping package="socalgas.model">

<class name="Milestone"
      table="tbl_milestones"
      lazy="true">

   <id name="id"
      type="long"
      column="fld_milestone_id"
      unsaved-value="null">
      <generator class="native"/>
   </id>

   <property   name="description"
                    type="string"
                    column="fld_milestone_desc"
                    not-null="true"/>

   <property   name="creationDate"
                    type="java.util.Date"
                    column="fld_milestone_creation_date"
                    not-null="true"/>
                               
        <many-to-one name="project"
                     class="Project"
                     column="fld_milestone_project_id"
                     cascade="save-update" />

        <many-to-one name="status"
                     class="Status"
                     column="fld_milestone_status_id"
                     cascade="save-update" />
</class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Below is an example method in one of my DAO objects
Quote:
UserDAO.java

Code:
public User getByName(String username){
        Session session = null;
        User user = null;
        List list;
        try{
            session = HibernateUtil.getSession();

            Criteria criteria = session.createCriteria(User.class);
            criteria.add(Expression.eq("username", username));
           
            list =(List) criteria.list();  //session.createCriteria(User.class).list();
           
            if(list.size() > 0) user = (User) list.get(0);
           
        }catch(HibernateException ex){
            throw new InfrastructureException(ex);
        }catch(Exception ex){
            throw new InfrastructureException(ex);
        }
        //throw new InfrastructureException("List size: " + list.size());
        return user;
    }


I use a HibernateUtil.java which is completely text book.
Code:
/*
* HibernateUtil.java
*
* Created on October 25, 2004, 6:11 AM
*/

package socalgas.util;
import net.sf.hibernate.*;
import net.sf.hibernate.cfg.*;
import socalgas.exceptions.*;


/**
*
* @author  Marco G. Williams
* Example: Taken from "Hibernate Bible"
*/
public class HibernateUtil {
    private static final SessionFactory sessionFactory;
    private static final ThreadLocal threadSession = new ThreadLocal();
    private static final ThreadLocal threadTransaction = new ThreadLocal();
   
    static{
        try {
            Configuration cfg = new Configuration();
            sessionFactory = cfg.configure().buildSessionFactory();
        }catch(Throwable ex){
            ex.printStackTrace(System.out);
            throw new ExceptionInInitializerError(ex);
        }
    }
   
    /** Creates a new instance of HibernateUtil */
    public HibernateUtil() {
    }
   
    public static Session getSession() throws HibernateException{
        Session s = (Session) threadSession.get();
        try{
            //System.out.println(s);
            if(s==null){
                s = sessionFactory.openSession();
                threadSession.set(s);
            }
        }catch (HibernateException ex){
            throw new InfrastructureException(ex);
        }
        //return sessionFactory.openSession();
        return s;
    }   

   
    public static void closeSession(){
        try{
            Session s = (Session) threadSession.get();
            threadSession.set(null);
            if(s!=null && s.isOpen()) s.close();
           
        }catch(HibernateException ex){
            throw new InfrastructureException(ex);
        }
    }

    public static void beginTransaction(){
        Transaction tx = (Transaction) threadTransaction.get();
        try{
            if( tx == null){
                tx = getSession().beginTransaction();
                threadTransaction.set(tx);
            }
        }catch(HibernateException ex){
            throw new InfrastructureException(ex);
        }
    }

    public static void commitTransaction(){
        Transaction tx = (Transaction) threadTransaction.get();
        try{
            if(tx!=null && !tx.wasCommitted() && !tx.wasRolledBack()) tx.commit();
            threadTransaction.set(null);
        }catch(HibernateException ex){
            rollbackTransaction();
            throw new InfrastructureException(ex);
        }
    }
   
    public static void rollbackTransaction(){
        Transaction tx = (Transaction) threadTransaction.get();
        try{
            threadTransaction.set(null);
            if(tx!=null && !tx.wasCommitted() && !tx.wasRolledBack()) tx.rollback();
        }catch(HibernateException ex){
            throw new InfrastructureException(ex);
        } finally{
            closeSession();
        }
       
    }

}


Full stack trace of any exception that occurs:
Quote:
The stack trace comes in two different ways.
If I run the application fresh. Meaning I clean and compile then run it on a newley restarted Tomcat Server. I always get this error:

Code:
NotifyUtil::java.net.SocketException: Software caused connection abort: recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:256)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:313)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:606)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:554)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:571)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:928)
    at org.netbeans.modules.web.monitor.server.NotifyUtil$RecordSender.run(NotifyUtil.java:248)


Quote:
If i leave my application running or Tomcat running for that matter, for more than my applications timeout period, I almost always get the following stacktrace in my browser:

Note: I accedently cleared the Tomcat Stack trace. But I will post a follow up with it next time it occurs.
Code:
javax.servlet.ServletException: net.sf.hibernate.JDBCException: SQLException occurred
   org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:516)
   org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:423)
   org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
   org.apache.struts.action.ActionServlet.process(ActionServlet.java:1158)
   org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)


root cause

socalgas.exceptions.InfrastructureException: net.sf.hibernate.JDBCException: SQLException occurred
   socalgas.dao.UserDAO.getByName(UserDAO.java:74)
   socalgas.actions.LoginAction.execute(LoginAction.java:44)
   org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
   org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
   org.apache.struts.action.ActionServlet.process(ActionServlet.java:1158)
   org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)


Name and version of the database you are using:
I'm running this on a MYSQL Database
Version 3.23.52-MAX
The generated SQL (show_sql=true):

The following SQL is what i get when I first try to login right before I get the error.
Code:
Hibernate: select this.id as id0_, this.username as username0_, this.customerid as customerid0_, this.roles as roles0_, this.userpassword as userpass5_0_, this.email as email0_ from users this where this.username=?
Hibernate: select this.fld_project_id as fld_proj1_2_, this.fld_project_name as fld_proj2_2_, this.fld_project_desc as fld_proj3_2_, this.fld_project_creation_date as fld_proj4_2_, this.fld_project_completion_date as fld_proj5_2_, this.fld_project_manager_id as fld_proj6_2_, this.fld_project_status_id as fld_proj7_2_, user1_.id as id0_, user1_.username as username0_, user1_.customerid as customerid0_, user1_.roles as roles0_, user1_.userpassword as userpass5_0_, user1_.email as email0_, status2_.fld_status_id as fld_stat1_1_, status2_.fld_status_desc as fld_stat2_1_ from tbl_projects this left outer join users user1_ on this.fld_project_manager_id=user1_.id left outer join tbl_status status2_ on this.fld_project_status_id=status2_.fld_status_id where 1=1



Debug level Hibernate log excerpt:
I'm not 100% sure how the hibernate logging works yet.
I'm just getting out of the rookie stage with java. I'm currently in
the process of RTFM *smiles* But I was asked to get this application
up and running quickly so I didn't have a lot of time.


I totally appreciate anyones help on this!
Thanks in advance,
Marco G. Williams
The Gas Company


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

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.