You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by abhishek jain <ab...@gmail.com> on 2011/03/01 07:09:49 UTC

Re: Exception in hibernate3

hi,
this didnt solved, i created a file c3po.properties with the mentioned
property and it didnt solved.
also i have to wait a day for the error message, is there a way where i can
reduce this time during test?


thanks
abhi

On Sat, Feb 26, 2011 at 12:32 AM, Burton Rhodes <bu...@gmail.com>wrote:

> I recall having a similiar issue when moving to MySQL from MSSQL.  I
> solved it by adding c3po.properties file to the classpath with the
> text below.  It kept the connection alive with the database.
>
> # This property corresponds to the query run defined by the
> "hibernate.c3p0.idle_test_period" value
> c3p0.preferredTestQuery = SELECT 1;
>
> On Fri, Feb 25, 2011 at 12:53 AM, Jerson John <je...@cprvision.com>
> wrote:
> > Hi,
> >
> >  Yup I faced this problem before and flush to Hibernate group.They have
> > suggested me some solution based on my mapping xml fle....Why don't u
> send
> > me that mapping xml and let me compare with mine.....Actually Even though
> it
> > look like Server error,its more to do with hibernate ....Please feel free
> to
> > currect me if my assumption is  wrong
> >
> > Many Thanks and Regards,
> >
> > Jerson
> >
> >
> > -----Original Message-----
> > From: abhishek jain [mailto:abhishek.netjain@gmail.com]
> > Sent: Friday, February 25, 2011 2:31 PM
> > To: Struts Users Mailing List
> > Subject: Exception in hibernate3
> >
> > hi,
> > I am not sure if i am ringing the correct list, but i am sure people here
> > must have encountered this problem. I am new to hibernate and when i ran
> the
> > code on server it was fine , strangely next day it keep on giving this
> error
> > till i restart tomcat.
> >
> > The last packet successfully received from the server was 54,880,316
> > milliseconds ago.  The last packet sent successfully to the server was
> > 54,880,317 milliseconds ago. is longer than the server configured value
> of
> > 'wait_timeout'. You should consider either expiring and/or testing
> > connection validity before use in your application, increasing the server
> > configured values for client timeouts, or using the Connector/J
> connection
> > property 'autoReconnect=true' to avoid this problem.
> >
> > I have searched a lot on net and added the following properties on
> > hibernate.cfg.xml, as people there were suggesting this,but of no use.
> > <!-- Sessions and transactions -->
> > <!-- Use the C3P0 connection pool provider -->
> > <property name="hibernate.c3p0.min_size">5</property>
> > <property name="hibernate.c3p0.max_size">20</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="current_session_context_class">thread</property>
> >
> >
> >
> > Pl. help me.
> > I have used hibernate3 with myeclipse as the development environment, and
> am
> > using mysql 5.x and centos (Linux) with Tomcat 5.x
> > --
>

Re: Exception in hibernate3

Posted by abhishek jain <ab...@gmail.com>.
Hello,
No, the query isnt running.
What do i need to do for this,
Also i have to wait for 8 hours to see if mysql has timeout with my code in
hibernate , cannt i reduce some values in hibernate.cfg.xml and test.
Can some one post the relevant sections of hte config file,

pl advice, i am now approaching application release date,

thanks
abhi

On Wed, Mar 9, 2011 at 2:30 AM, Burton Rhodes <bu...@gmail.com>wrote:

> There are a number of ways to do this, either by java (log4j for
> exmaple) or directly via your database.  If you are using MySQL
> perhaps you do it this way....
>
> http://www.howtogeek.com/howto/database/monitor-all-sql-queries-in-mysql/
>
>
> On Mon, Mar 7, 2011 at 12:34 AM, abhishek jain
> <ab...@gmail.com> wrote:
> > No, i havent setup logs, but apparently it is not running else there
> would
> > have been no exception message.
> > Hey, can you guide me to the correct setup, i have asked this on
> hibernate
> > forumns but apparently they are slow in replying , no response yet,
> >
> > Pl. help
> > thanks
> > abhishek
> >
> >
> > On Sun, Mar 6, 2011 at 3:55 AM, Burton Rhodes <bu...@gmail.com>
> > wrote:
> >>
> >> Have u set up you logs to verify that your 'select 1' query is
> >> actually being run?
> >>
> >> On Saturday, March 5, 2011, Dave Newton <da...@gmail.com> wrote:
> >> > If this question is related to hibernate it'd be more efficient and
> >> > appropriate to ask on a hibernate-related list probably.
> >> >
> >> > Dave
> >> >  On Mar 5, 2011 3:32 AM, "abhishek jain" <ab...@gmail.com>
> >> > wrote:
> >> >> hi,
> >> >> thanks for the mail,
> >> >> i tried this but the problem still persists, i added the context.xml
> >> >> file
> >> > in
> >> >> META-INF and the database information was not being picked from
> there.
> >> >> Also i added the connect-timeout parameter in my.cnf file in the
> mysqld
> >> >> section, but still the the timeout was after 8 hours of inactivity.
> >> >>
> >> >> I will appreciate if one can tell me exactly what to do, pl consider
> me
> >> >> a
> >> >> newbie and will appreciate if the instructions be given.
> >> >>
> >> >> thanks
> >> >> abhishek
> >> >>
> >> >> On Tue, Mar 1, 2011 at 3:26 PM, Maurizio Cucchiara <
> >> >> maurizio.cucchiara@gmail.com> wrote:
> >> >>
> >> >>> I struggled with this issue for a long period, at the end I reached
> a
> >> >>> good point: I started using database connection pools [1].
> >> >>> Actually you should wait until the mysql connection dies (it should
> be
> >> >>> after 8 hours of db inactivity ), but you could change the
> >> >>> connect-timeout=seconds [2] in order to achieve the before mentioned
> >> >>> scenario.
> >> >>>
> >> >>> [1] http://commons.apache.org/dbcp/
> >> >>> [2] http://dev.mysql.com/doc/refman/5.5/en/mysql-options.html
> >> >>>
> >> >>>
> >> >>> Here my context.xml is:
> >> >>>
> >> >>> <Context
> >> >>> override="true"
> >> >>> reloadable="false"
> >> >>> unpackWARs="true" autoDeploy="true"
> >> >>> liveDeploy="false" allowLinking="true">
> >> >>> <!--
> >> >>> maxActive=10
> >> >>> Don't set this any higher than max_connections on your
> >> >>> MySQL server, usually this should be a 10 or a few 10's
> >> >>> of connections, not hundreds or thousands
> >> >>> -->
> >> >>> <!--
> >> >>> maxIdle=5
> >> >>> You don't want to many idle connections hanging around
> >> >>> if you can avoid it, only enough to soak up a spike in
> >> >>> the load
> >> >>> -->
> >> >>> <!--
> >> >>> validationQuery=select 1
> >> >>> Don't use autoReconnect=true, it's going away eventually
> >> >>> and it's a crutch for older connection pools that couldn't
> >> >>> test connections. You need to decide whether your application
> >> >>> is supposed to deal with SQLExceptions (hint, it should), and
> >> >>> how much of a performance penalty you're willing to pay
> >> >>> to ensure 'freshness' of the connection
> >> >>> -->
> >> >>>
> >> >>> <!--
> >> >>> testOnBorrow=true
> >> >>> The most conservative approach is to test connections
> >> >>> before they're given to your application. For most applications
> >> >>> this is okay, the query used above is very small and takes
> >> >>> no real server resources to process, other than the time used
> >> >>> to traverse the network.
> >> >>>
> >> >>> If you have a high-load application you'll need to rely on
> >> >>> something else.
> >> >>> -->
> >> >>> <!--
> >> >>> testWhileIdle=true
> >> >>> Otherwise, or in addition to testOnBorrow, you can test
> >> >>> while connections are sitting idle
> >> >>> -->
> >> >>> <!--
> >> >>> timeBetweenEvictionRunsMillis=10000
> >> >>> You have to set this value, otherwise even though
> >> >>> you've asked connections to be tested while idle,
> >> >>> the idle evicter thread will never run
> >> >>> -->
> >> >>> <!--
> >> >>> minEvictableIdleTimeMillis=60000
> >> >>> Don't allow connections to hang out idle too long,
> >> >>> never longer than what wait_timeout is set to on the
> >> >>> server...A few minutes or even fraction of a minute
> >> >>> is sometimes okay here, it depends on your application
> >> >>> and how much spikey load it will see
> >> >>> -->
> >> >>> <!--
> >> >>> maxWait
> >> >>> Maximum time to wait for a dB connection to become available
> >> >>> in ms, in this example 10 seconds. An Exception is thrown if
> >> >>> this timeout is exceeded. Set to -1 to wait indefinitely.
> >> >>> -->
> >> >>> <!--
> >> >>> removeAbandoned=true
> >> >>>
> >> >>> A database connection pool creates and manages a pool of
> >> >>> connections to a database. Recycling and reusing already
> >> >>> existing connections
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

Re: Exception in hibernate3

Posted by abhishek jain <ab...@gmail.com>.
No, i havent setup logs, but apparently it is not running else there would
have been no exception message.
Hey, can you guide me to the correct setup, i have asked this on hibernate
forumns but apparently they are slow in replying , no response yet,

Pl. help
thanks
abhishek


On Sun, Mar 6, 2011 at 3:55 AM, Burton Rhodes <bu...@gmail.com>wrote:

> Have u set up you logs to verify that your 'select 1' query is
> actually being run?
>
> On Saturday, March 5, 2011, Dave Newton <da...@gmail.com> wrote:
> > If this question is related to hibernate it'd be more efficient and
> > appropriate to ask on a hibernate-related list probably.
> >
> > Dave
> >  On Mar 5, 2011 3:32 AM, "abhishek jain" <ab...@gmail.com>
> wrote:
> >> hi,
> >> thanks for the mail,
> >> i tried this but the problem still persists, i added the context.xml
> file
> > in
> >> META-INF and the database information was not being picked from there.
> >> Also i added the connect-timeout parameter in my.cnf file in the mysqld
> >> section, but still the the timeout was after 8 hours of inactivity.
> >>
> >> I will appreciate if one can tell me exactly what to do, pl consider me
> a
> >> newbie and will appreciate if the instructions be given.
> >>
> >> thanks
> >> abhishek
> >>
> >> On Tue, Mar 1, 2011 at 3:26 PM, Maurizio Cucchiara <
> >> maurizio.cucchiara@gmail.com> wrote:
> >>
> >>> I struggled with this issue for a long period, at the end I reached a
> >>> good point: I started using database connection pools [1].
> >>> Actually you should wait until the mysql connection dies (it should be
> >>> after 8 hours of db inactivity ), but you could change the
> >>> connect-timeout=seconds [2] in order to achieve the before mentioned
> >>> scenario.
> >>>
> >>> [1] http://commons.apache.org/dbcp/
> >>> [2] http://dev.mysql.com/doc/refman/5.5/en/mysql-options.html
> >>>
> >>>
> >>> Here my context.xml is:
> >>>
> >>> <Context
> >>> override="true"
> >>> reloadable="false"
> >>> unpackWARs="true" autoDeploy="true"
> >>> liveDeploy="false" allowLinking="true">
> >>> <!--
> >>> maxActive=10
> >>> Don't set this any higher than max_connections on your
> >>> MySQL server, usually this should be a 10 or a few 10's
> >>> of connections, not hundreds or thousands
> >>> -->
> >>> <!--
> >>> maxIdle=5
> >>> You don't want to many idle connections hanging around
> >>> if you can avoid it, only enough to soak up a spike in
> >>> the load
> >>> -->
> >>> <!--
> >>> validationQuery=select 1
> >>> Don't use autoReconnect=true, it's going away eventually
> >>> and it's a crutch for older connection pools that couldn't
> >>> test connections. You need to decide whether your application
> >>> is supposed to deal with SQLExceptions (hint, it should), and
> >>> how much of a performance penalty you're willing to pay
> >>> to ensure 'freshness' of the connection
> >>> -->
> >>>
> >>> <!--
> >>> testOnBorrow=true
> >>> The most conservative approach is to test connections
> >>> before they're given to your application. For most applications
> >>> this is okay, the query used above is very small and takes
> >>> no real server resources to process, other than the time used
> >>> to traverse the network.
> >>>
> >>> If you have a high-load application you'll need to rely on
> >>> something else.
> >>> -->
> >>> <!--
> >>> testWhileIdle=true
> >>> Otherwise, or in addition to testOnBorrow, you can test
> >>> while connections are sitting idle
> >>> -->
> >>> <!--
> >>> timeBetweenEvictionRunsMillis=10000
> >>> You have to set this value, otherwise even though
> >>> you've asked connections to be tested while idle,
> >>> the idle evicter thread will never run
> >>> -->
> >>> <!--
> >>> minEvictableIdleTimeMillis=60000
> >>> Don't allow connections to hang out idle too long,
> >>> never longer than what wait_timeout is set to on the
> >>> server...A few minutes or even fraction of a minute
> >>> is sometimes okay here, it depends on your application
> >>> and how much spikey load it will see
> >>> -->
> >>> <!--
> >>> maxWait
> >>> Maximum time to wait for a dB connection to become available
> >>> in ms, in this example 10 seconds. An Exception is thrown if
> >>> this timeout is exceeded. Set to -1 to wait indefinitely.
> >>> -->
> >>> <!--
> >>> removeAbandoned=true
> >>>
> >>> A database connection pool creates and manages a pool of
> >>> connections to a database. Recycling and reusing already
> >>> existing connections
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

Re: Exception in hibernate3

Posted by Burton Rhodes <bu...@gmail.com>.
Have u set up you logs to verify that your 'select 1' query is
actually being run?

On Saturday, March 5, 2011, Dave Newton <da...@gmail.com> wrote:
> If this question is related to hibernate it'd be more efficient and
> appropriate to ask on a hibernate-related list probably.
>
> Dave
>  On Mar 5, 2011 3:32 AM, "abhishek jain" <ab...@gmail.com> wrote:
>> hi,
>> thanks for the mail,
>> i tried this but the problem still persists, i added the context.xml file
> in
>> META-INF and the database information was not being picked from there.
>> Also i added the connect-timeout parameter in my.cnf file in the mysqld
>> section, but still the the timeout was after 8 hours of inactivity.
>>
>> I will appreciate if one can tell me exactly what to do, pl consider me a
>> newbie and will appreciate if the instructions be given.
>>
>> thanks
>> abhishek
>>
>> On Tue, Mar 1, 2011 at 3:26 PM, Maurizio Cucchiara <
>> maurizio.cucchiara@gmail.com> wrote:
>>
>>> I struggled with this issue for a long period, at the end I reached a
>>> good point: I started using database connection pools [1].
>>> Actually you should wait until the mysql connection dies (it should be
>>> after 8 hours of db inactivity ), but you could change the
>>> connect-timeout=seconds [2] in order to achieve the before mentioned
>>> scenario.
>>>
>>> [1] http://commons.apache.org/dbcp/
>>> [2] http://dev.mysql.com/doc/refman/5.5/en/mysql-options.html
>>>
>>>
>>> Here my context.xml is:
>>>
>>> <Context
>>> override="true"
>>> reloadable="false"
>>> unpackWARs="true" autoDeploy="true"
>>> liveDeploy="false" allowLinking="true">
>>> <!--
>>> maxActive=10
>>> Don't set this any higher than max_connections on your
>>> MySQL server, usually this should be a 10 or a few 10's
>>> of connections, not hundreds or thousands
>>> -->
>>> <!--
>>> maxIdle=5
>>> You don't want to many idle connections hanging around
>>> if you can avoid it, only enough to soak up a spike in
>>> the load
>>> -->
>>> <!--
>>> validationQuery=select 1
>>> Don't use autoReconnect=true, it's going away eventually
>>> and it's a crutch for older connection pools that couldn't
>>> test connections. You need to decide whether your application
>>> is supposed to deal with SQLExceptions (hint, it should), and
>>> how much of a performance penalty you're willing to pay
>>> to ensure 'freshness' of the connection
>>> -->
>>>
>>> <!--
>>> testOnBorrow=true
>>> The most conservative approach is to test connections
>>> before they're given to your application. For most applications
>>> this is okay, the query used above is very small and takes
>>> no real server resources to process, other than the time used
>>> to traverse the network.
>>>
>>> If you have a high-load application you'll need to rely on
>>> something else.
>>> -->
>>> <!--
>>> testWhileIdle=true
>>> Otherwise, or in addition to testOnBorrow, you can test
>>> while connections are sitting idle
>>> -->
>>> <!--
>>> timeBetweenEvictionRunsMillis=10000
>>> You have to set this value, otherwise even though
>>> you've asked connections to be tested while idle,
>>> the idle evicter thread will never run
>>> -->
>>> <!--
>>> minEvictableIdleTimeMillis=60000
>>> Don't allow connections to hang out idle too long,
>>> never longer than what wait_timeout is set to on the
>>> server...A few minutes or even fraction of a minute
>>> is sometimes okay here, it depends on your application
>>> and how much spikey load it will see
>>> -->
>>> <!--
>>> maxWait
>>> Maximum time to wait for a dB connection to become available
>>> in ms, in this example 10 seconds. An Exception is thrown if
>>> this timeout is exceeded. Set to -1 to wait indefinitely.
>>> -->
>>> <!--
>>> removeAbandoned=true
>>>
>>> A database connection pool creates and manages a pool of
>>> connections to a database. Recycling and reusing already
>>> existing connections

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Exception in hibernate3

Posted by Dave Newton <da...@gmail.com>.
If this question is related to hibernate it'd be more efficient and
appropriate to ask on a hibernate-related list probably.

Dave
 On Mar 5, 2011 3:32 AM, "abhishek jain" <ab...@gmail.com> wrote:
> hi,
> thanks for the mail,
> i tried this but the problem still persists, i added the context.xml file
in
> META-INF and the database information was not being picked from there.
> Also i added the connect-timeout parameter in my.cnf file in the mysqld
> section, but still the the timeout was after 8 hours of inactivity.
>
> I will appreciate if one can tell me exactly what to do, pl consider me a
> newbie and will appreciate if the instructions be given.
>
> thanks
> abhishek
>
> On Tue, Mar 1, 2011 at 3:26 PM, Maurizio Cucchiara <
> maurizio.cucchiara@gmail.com> wrote:
>
>> I struggled with this issue for a long period, at the end I reached a
>> good point: I started using database connection pools [1].
>> Actually you should wait until the mysql connection dies (it should be
>> after 8 hours of db inactivity ), but you could change the
>> connect-timeout=seconds [2] in order to achieve the before mentioned
>> scenario.
>>
>> [1] http://commons.apache.org/dbcp/
>> [2] http://dev.mysql.com/doc/refman/5.5/en/mysql-options.html
>>
>>
>> Here my context.xml is:
>>
>> <Context
>> override="true"
>> reloadable="false"
>> unpackWARs="true" autoDeploy="true"
>> liveDeploy="false" allowLinking="true">
>> <!--
>> maxActive=10
>> Don't set this any higher than max_connections on your
>> MySQL server, usually this should be a 10 or a few 10's
>> of connections, not hundreds or thousands
>> -->
>> <!--
>> maxIdle=5
>> You don't want to many idle connections hanging around
>> if you can avoid it, only enough to soak up a spike in
>> the load
>> -->
>> <!--
>> validationQuery=select 1
>> Don't use autoReconnect=true, it's going away eventually
>> and it's a crutch for older connection pools that couldn't
>> test connections. You need to decide whether your application
>> is supposed to deal with SQLExceptions (hint, it should), and
>> how much of a performance penalty you're willing to pay
>> to ensure 'freshness' of the connection
>> -->
>>
>> <!--
>> testOnBorrow=true
>> The most conservative approach is to test connections
>> before they're given to your application. For most applications
>> this is okay, the query used above is very small and takes
>> no real server resources to process, other than the time used
>> to traverse the network.
>>
>> If you have a high-load application you'll need to rely on
>> something else.
>> -->
>> <!--
>> testWhileIdle=true
>> Otherwise, or in addition to testOnBorrow, you can test
>> while connections are sitting idle
>> -->
>> <!--
>> timeBetweenEvictionRunsMillis=10000
>> You have to set this value, otherwise even though
>> you've asked connections to be tested while idle,
>> the idle evicter thread will never run
>> -->
>> <!--
>> minEvictableIdleTimeMillis=60000
>> Don't allow connections to hang out idle too long,
>> never longer than what wait_timeout is set to on the
>> server...A few minutes or even fraction of a minute
>> is sometimes okay here, it depends on your application
>> and how much spikey load it will see
>> -->
>> <!--
>> maxWait
>> Maximum time to wait for a dB connection to become available
>> in ms, in this example 10 seconds. An Exception is thrown if
>> this timeout is exceeded. Set to -1 to wait indefinitely.
>> -->
>> <!--
>> removeAbandoned=true
>>
>> A database connection pool creates and manages a pool of
>> connections to a database. Recycling and reusing already
>> existing connections to a dB is more efficient than opening a
>> new connection.
>>
>> There is one problem with connection pooling. A web
>> application has to explicetely close ResultSet's, Statement's,
>> and Connection's.
>> Failure of a web application to close these resources can
>> result in them never being available again for reuse,
>> a db connection pool "leak". This can eventually result in
>> your web application db connections failing if there
>> are no more available connections.
>>
>> There is a solution to this problem. The Jakarta-Commons DBCP
>> can be configured to track and recover these
>> abandoned dB connections. Not only can it recover them, but
>> also generate a stack trace for the code which
>> opened these resources and never closed them.
>>
>> -->
>> <!--
>> removeAbandonedTimeout="60"
>> Use the removeAbandonedTimeout attribute to set the number of
>> seconds a dB connection has been idle before it
>> is considered abandoned.
>> -->
>> <!--
>> logAbandoned=true
>> The logAbandoned attribute can be set to true if you want DBCP
>> to log a stack trace of the code which abandoned
>> the dB connection resources.
>> -->
>> <Resource
>> type="javax.sql.DataSource"
>> name="jdbc/${CONTEXT_NAME}"
>> password="PASSWORD"
>> driverClassName="org.gjt.mm.mysql.Driver"
>> username="${USERNAME}"
>>
>>
url="jdbc:mysql://localhost/${DB_NAME}?zeroDateTimeBehavior=convertToNull"
>> auth="Container"
>> factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
>> maxActive="20"
>> maxIdle="5"
>> validationQuery="select 1"
>> testOnBorrow="true"
>> testWhileIdle="true"
>> timeBetweenEvictionRunsMillis="10000"
>> minEvictableIdleTimeMillis="60000"
>> maxWait="5000"
>> removeAbandoned="true"
>> removeAbandonedTimeout="60"
>> logAbandoned="true"
>> />
>> </Context>
>>
>>
>> On 1 March 2011 07:09, abhishek jain <ab...@gmail.com> wrote:
>> > hi,
>> > this didnt solved, i created a file c3po.properties with the mentioned
>> > property and it didnt solved.
>> > also i have to wait a day for the error message, is there a way where i
>> can
>> > reduce this time during test?
>> >
>> >
>> > thanks
>> > abhi
>> >
>> > On Sat, Feb 26, 2011 at 12:32 AM, Burton Rhodes <burtonrhodes@gmail.com
>> >wrote:
>> >
>> >> I recall having a similiar issue when moving to MySQL from MSSQL. I
>> >> solved it by adding c3po.properties file to the classpath with the
>> >> text below. It kept the connection alive with the database.
>> >>
>> >> # This property corresponds to the query run defined by the
>> >> "hibernate.c3p0.idle_test_period" value
>> >> c3p0.preferredTestQuery = SELECT 1;
>> >>
>> >> On Fri, Feb 25, 2011 at 12:53 AM, Jerson John <je...@cprvision.com>
>> >> wrote:
>> >> > Hi,
>> >> >
>> >> > Yup I faced this problem before and flush to Hibernate group.They
>> have
>> >> > suggested me some solution based on my mapping xml fle....Why don't
u
>> >> send
>> >> > me that mapping xml and let me compare with mine.....Actually Even
>> though
>> >> it
>> >> > look like Server error,its more to do with hibernate ....Please feel
>> free
>> >> to
>> >> > currect me if my assumption is wrong
>> >> >
>> >> > Many Thanks and Regards,
>> >> >
>> >> > Jerson
>> >> >
>> >> >
>> >> > -----Original Message-----
>> >> > From: abhishek jain [mailto:abhishek.netjain@gmail.com]
>> >> > Sent: Friday, February 25, 2011 2:31 PM
>> >> > To: Struts Users Mailing List
>> >> > Subject: Exception in hibernate3
>> >> >
>> >> > hi,
>> >> > I am not sure if i am ringing the correct list, but i am sure people
>> here
>> >> > must have encountered this problem. I am new to hibernate and when i
>> ran
>> >> the
>> >> > code on server it was fine , strangely next day it keep on giving
this
>> >> error
>> >> > till i restart tomcat.
>> >> >
>> >> > The last packet successfully received from the server was 54,880,316
>> >> > milliseconds ago. The last packet sent successfully to the server
was
>> >> > 54,880,317 milliseconds ago. is longer than the server configured
>> value
>> >> of
>> >> > 'wait_timeout'. You should consider either expiring and/or testing
>> >> > connection validity before use in your application, increasing the
>> server
>> >> > configured values for client timeouts, or using the Connector/J
>> >> connection
>> >> > property 'autoReconnect=true' to avoid this problem.
>> >> >
>> >> > I have searched a lot on net and added the following properties on
>> >> > hibernate.cfg.xml, as people there were suggesting this,but of no
use.
>> >> > <!-- Sessions and transactions -->
>> >> > <!-- Use the C3P0 connection pool provider -->
>> >> > <property name="hibernate.c3p0.min_size">5</property>
>> >> > <property name="hibernate.c3p0.max_size">20</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="current_session_context_class">thread</property>
>> >> >
>> >> >
>> >> >
>> >> > Pl. help me.
>> >> > I have used hibernate3 with myeclipse as the development
environment,
>> and
>> >> am
>> >> > using mysql 5.x and centos (Linux) with Tomcat 5.x
>> >> > --
>> >>
>> >
>>
>>
>>
>> --
>> Maurizio Cucchiara
>>
>>

Re: Exception in hibernate3

Posted by abhishek jain <ab...@gmail.com>.
hi,
thanks for the mail,
i tried this but the problem still persists, i added the context.xml file in
META-INF and the database information was not being picked from there.
Also i added the connect-timeout parameter in my.cnf file in the mysqld
section, but still the the timeout was after 8 hours of inactivity.

I will appreciate if one can tell me exactly what to do, pl consider me a
newbie and will appreciate if the instructions be given.

thanks
abhishek

On Tue, Mar 1, 2011 at 3:26 PM, Maurizio Cucchiara <
maurizio.cucchiara@gmail.com> wrote:

> I struggled with this issue for a long period, at the end I reached a
> good point: I started using database connection pools [1].
> Actually you should wait until the mysql connection dies (it should be
> after 8 hours of db inactivity ), but you could change the
> connect-timeout=seconds [2] in order to achieve the before mentioned
> scenario.
>
> [1] http://commons.apache.org/dbcp/
> [2] http://dev.mysql.com/doc/refman/5.5/en/mysql-options.html
>
>
> Here my context.xml is:
>
> <Context
>        override="true"
>        reloadable="false"
>        unpackWARs="true" autoDeploy="true"
>        liveDeploy="false" allowLinking="true">
>    <!--
>        maxActive=10
>        Don't set this any higher than max_connections on your
>        MySQL server, usually this should be a 10 or a few 10's
>        of connections, not hundreds or thousands
>    -->
>   <!--
>        maxIdle=5
>        You don't want to many idle connections hanging around
>        if you can avoid it, only enough to soak up a spike in
>        the load
>    -->
>    <!--
>        validationQuery=select 1
>        Don't use autoReconnect=true, it's going away eventually
>        and it's a crutch for older connection pools that couldn't
>        test connections. You need to decide whether your application
>        is supposed to deal with SQLExceptions (hint, it should), and
>        how much of a performance penalty you're willing to pay
>        to ensure 'freshness' of the connection
>    -->
>
>    <!--
>        testOnBorrow=true
>        The most conservative approach is to test connections
>        before they're given to your application. For most applications
>        this is okay, the query used above is very small and takes
>        no real server resources to process, other than the time used
>        to traverse the network.
>
>        If you have a high-load application you'll need to rely on
>        something else.
>    -->
>    <!--
>        testWhileIdle=true
>        Otherwise, or in addition to testOnBorrow, you can test
>        while connections are sitting idle
>     -->
>    <!--
>        timeBetweenEvictionRunsMillis=10000
>        You have to set this value, otherwise even though
>        you've asked connections to be tested while idle,
>        the idle evicter thread will never run
>    -->
>    <!--
>        minEvictableIdleTimeMillis=60000
>        Don't allow connections to hang out idle too long,
>        never longer than what wait_timeout is set to on the
>        server...A few minutes or even fraction of a minute
>        is sometimes okay here, it depends on your application
>        and how much spikey load it will see
>    -->
>    <!--
>        maxWait
>        Maximum time to wait for a dB connection to become available
>        in ms, in this example 10 seconds. An Exception is thrown if
>        this timeout is exceeded.  Set to -1 to wait indefinitely.
>    -->
>    <!--
>        removeAbandoned=true
>
>        A database connection pool creates and manages a pool of
> connections to a database. Recycling and reusing already
>        existing connections to a dB is more efficient than opening a
> new connection.
>
>        There is one problem with connection pooling. A web
> application has to explicetely close ResultSet's, Statement's,
>        and Connection's.
>        Failure of a web application to close these resources can
> result in them never being available again for reuse,
>        a db connection pool "leak". This can eventually result in
> your web application db connections failing if there
>        are no more available connections.
>
>        There is a solution to this problem. The Jakarta-Commons DBCP
> can be configured to track and recover these
>        abandoned dB connections. Not only can it recover them, but
> also generate a stack trace for the code which
>        opened these resources and never closed them.
>
>    -->
>    <!--
>        removeAbandonedTimeout="60"
>        Use the removeAbandonedTimeout attribute to set the number of
> seconds a dB connection has been idle before it
>        is considered abandoned.
>    -->
>    <!--
>        logAbandoned=true
>        The logAbandoned attribute can be set to true if you want DBCP
> to log a stack trace of the code which abandoned
>        the dB connection resources.
>    -->
>    <Resource
>            type="javax.sql.DataSource"
>            name="jdbc/${CONTEXT_NAME}"
>            password="PASSWORD"
>            driverClassName="org.gjt.mm.mysql.Driver"
>            username="${USERNAME}"
>
>  url="jdbc:mysql://localhost/${DB_NAME}?zeroDateTimeBehavior=convertToNull"
>            auth="Container"
>            factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
>            maxActive="20"
>            maxIdle="5"
>            validationQuery="select 1"
>            testOnBorrow="true"
>            testWhileIdle="true"
>            timeBetweenEvictionRunsMillis="10000"
>            minEvictableIdleTimeMillis="60000"
>            maxWait="5000"
>            removeAbandoned="true"
>            removeAbandonedTimeout="60"
>            logAbandoned="true"
>            />
> </Context>
>
>
> On 1 March 2011 07:09, abhishek jain <ab...@gmail.com> wrote:
> > hi,
> > this didnt solved, i created a file c3po.properties with the mentioned
> > property and it didnt solved.
> > also i have to wait a day for the error message, is there a way where i
> can
> > reduce this time during test?
> >
> >
> > thanks
> > abhi
> >
> > On Sat, Feb 26, 2011 at 12:32 AM, Burton Rhodes <burtonrhodes@gmail.com
> >wrote:
> >
> >> I recall having a similiar issue when moving to MySQL from MSSQL.  I
> >> solved it by adding c3po.properties file to the classpath with the
> >> text below.  It kept the connection alive with the database.
> >>
> >> # This property corresponds to the query run defined by the
> >> "hibernate.c3p0.idle_test_period" value
> >> c3p0.preferredTestQuery = SELECT 1;
> >>
> >> On Fri, Feb 25, 2011 at 12:53 AM, Jerson John <je...@cprvision.com>
> >> wrote:
> >> > Hi,
> >> >
> >> >  Yup I faced this problem before and flush to Hibernate group.They
> have
> >> > suggested me some solution based on my mapping xml fle....Why don't u
> >> send
> >> > me that mapping xml and let me compare with mine.....Actually Even
> though
> >> it
> >> > look like Server error,its more to do with hibernate ....Please feel
> free
> >> to
> >> > currect me if my assumption is  wrong
> >> >
> >> > Many Thanks and Regards,
> >> >
> >> > Jerson
> >> >
> >> >
> >> > -----Original Message-----
> >> > From: abhishek jain [mailto:abhishek.netjain@gmail.com]
> >> > Sent: Friday, February 25, 2011 2:31 PM
> >> > To: Struts Users Mailing List
> >> > Subject: Exception in hibernate3
> >> >
> >> > hi,
> >> > I am not sure if i am ringing the correct list, but i am sure people
> here
> >> > must have encountered this problem. I am new to hibernate and when i
> ran
> >> the
> >> > code on server it was fine , strangely next day it keep on giving this
> >> error
> >> > till i restart tomcat.
> >> >
> >> > The last packet successfully received from the server was 54,880,316
> >> > milliseconds ago.  The last packet sent successfully to the server was
> >> > 54,880,317 milliseconds ago. is longer than the server configured
> value
> >> of
> >> > 'wait_timeout'. You should consider either expiring and/or testing
> >> > connection validity before use in your application, increasing the
> server
> >> > configured values for client timeouts, or using the Connector/J
> >> connection
> >> > property 'autoReconnect=true' to avoid this problem.
> >> >
> >> > I have searched a lot on net and added the following properties on
> >> > hibernate.cfg.xml, as people there were suggesting this,but of no use.
> >> > <!-- Sessions and transactions -->
> >> > <!-- Use the C3P0 connection pool provider -->
> >> > <property name="hibernate.c3p0.min_size">5</property>
> >> > <property name="hibernate.c3p0.max_size">20</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="current_session_context_class">thread</property>
> >> >
> >> >
> >> >
> >> > Pl. help me.
> >> > I have used hibernate3 with myeclipse as the development environment,
> and
> >> am
> >> > using mysql 5.x and centos (Linux) with Tomcat 5.x
> >> > --
> >>
> >
>
>
>
> --
> Maurizio Cucchiara
>
>

Re: Exception in hibernate3

Posted by Maurizio Cucchiara <ma...@gmail.com>.
I struggled with this issue for a long period, at the end I reached a
good point: I started using database connection pools [1].
Actually you should wait until the mysql connection dies (it should be
after 8 hours of db inactivity ), but you could change the
connect-timeout=seconds [2] in order to achieve the before mentioned
scenario.

[1] http://commons.apache.org/dbcp/
[2] http://dev.mysql.com/doc/refman/5.5/en/mysql-options.html


Here my context.xml is:

<Context
        override="true"
        reloadable="false"
        unpackWARs="true" autoDeploy="true"
        liveDeploy="false" allowLinking="true">
    <!--
        maxActive=10
        Don't set this any higher than max_connections on your
        MySQL server, usually this should be a 10 or a few 10's
        of connections, not hundreds or thousands
    -->
   <!--
        maxIdle=5
        You don't want to many idle connections hanging around
        if you can avoid it, only enough to soak up a spike in
        the load
    -->
    <!--
        validationQuery=select 1
        Don't use autoReconnect=true, it's going away eventually
        and it's a crutch for older connection pools that couldn't
        test connections. You need to decide whether your application
        is supposed to deal with SQLExceptions (hint, it should), and
        how much of a performance penalty you're willing to pay
        to ensure 'freshness' of the connection
    -->

    <!--
        testOnBorrow=true
        The most conservative approach is to test connections
        before they're given to your application. For most applications
        this is okay, the query used above is very small and takes
        no real server resources to process, other than the time used
        to traverse the network.

        If you have a high-load application you'll need to rely on
        something else.
    -->
    <!--
        testWhileIdle=true
        Otherwise, or in addition to testOnBorrow, you can test
        while connections are sitting idle
     -->
    <!--
        timeBetweenEvictionRunsMillis=10000
        You have to set this value, otherwise even though
        you've asked connections to be tested while idle,
        the idle evicter thread will never run
    -->
    <!--
        minEvictableIdleTimeMillis=60000
        Don't allow connections to hang out idle too long,
        never longer than what wait_timeout is set to on the
        server...A few minutes or even fraction of a minute
        is sometimes okay here, it depends on your application
        and how much spikey load it will see
    -->
    <!--
        maxWait
        Maximum time to wait for a dB connection to become available
        in ms, in this example 10 seconds. An Exception is thrown if
        this timeout is exceeded.  Set to -1 to wait indefinitely.
    -->
    <!--
        removeAbandoned=true

        A database connection pool creates and manages a pool of
connections to a database. Recycling and reusing already
        existing connections to a dB is more efficient than opening a
new connection.

        There is one problem with connection pooling. A web
application has to explicetely close ResultSet's, Statement's,
        and Connection's.
        Failure of a web application to close these resources can
result in them never being available again for reuse,
        a db connection pool "leak". This can eventually result in
your web application db connections failing if there
        are no more available connections.

        There is a solution to this problem. The Jakarta-Commons DBCP
can be configured to track and recover these
        abandoned dB connections. Not only can it recover them, but
also generate a stack trace for the code which
        opened these resources and never closed them.

    -->
    <!--
        removeAbandonedTimeout="60"
        Use the removeAbandonedTimeout attribute to set the number of
seconds a dB connection has been idle before it
        is considered abandoned.
    -->
    <!--
        logAbandoned=true
        The logAbandoned attribute can be set to true if you want DBCP
to log a stack trace of the code which abandoned
        the dB connection resources.
    -->
    <Resource
            type="javax.sql.DataSource"
            name="jdbc/${CONTEXT_NAME}"
            password="PASSWORD"
            driverClassName="org.gjt.mm.mysql.Driver"
            username="${USERNAME}"
            url="jdbc:mysql://localhost/${DB_NAME}?zeroDateTimeBehavior=convertToNull"
            auth="Container"
            factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
            maxActive="20"
            maxIdle="5"
            validationQuery="select 1"
            testOnBorrow="true"
            testWhileIdle="true"
            timeBetweenEvictionRunsMillis="10000"
            minEvictableIdleTimeMillis="60000"
            maxWait="5000"
            removeAbandoned="true"
            removeAbandonedTimeout="60"
            logAbandoned="true"
            />
</Context>


On 1 March 2011 07:09, abhishek jain <ab...@gmail.com> wrote:
> hi,
> this didnt solved, i created a file c3po.properties with the mentioned
> property and it didnt solved.
> also i have to wait a day for the error message, is there a way where i can
> reduce this time during test?
>
>
> thanks
> abhi
>
> On Sat, Feb 26, 2011 at 12:32 AM, Burton Rhodes <bu...@gmail.com>wrote:
>
>> I recall having a similiar issue when moving to MySQL from MSSQL.  I
>> solved it by adding c3po.properties file to the classpath with the
>> text below.  It kept the connection alive with the database.
>>
>> # This property corresponds to the query run defined by the
>> "hibernate.c3p0.idle_test_period" value
>> c3p0.preferredTestQuery = SELECT 1;
>>
>> On Fri, Feb 25, 2011 at 12:53 AM, Jerson John <je...@cprvision.com>
>> wrote:
>> > Hi,
>> >
>> >  Yup I faced this problem before and flush to Hibernate group.They have
>> > suggested me some solution based on my mapping xml fle....Why don't u
>> send
>> > me that mapping xml and let me compare with mine.....Actually Even though
>> it
>> > look like Server error,its more to do with hibernate ....Please feel free
>> to
>> > currect me if my assumption is  wrong
>> >
>> > Many Thanks and Regards,
>> >
>> > Jerson
>> >
>> >
>> > -----Original Message-----
>> > From: abhishek jain [mailto:abhishek.netjain@gmail.com]
>> > Sent: Friday, February 25, 2011 2:31 PM
>> > To: Struts Users Mailing List
>> > Subject: Exception in hibernate3
>> >
>> > hi,
>> > I am not sure if i am ringing the correct list, but i am sure people here
>> > must have encountered this problem. I am new to hibernate and when i ran
>> the
>> > code on server it was fine , strangely next day it keep on giving this
>> error
>> > till i restart tomcat.
>> >
>> > The last packet successfully received from the server was 54,880,316
>> > milliseconds ago.  The last packet sent successfully to the server was
>> > 54,880,317 milliseconds ago. is longer than the server configured value
>> of
>> > 'wait_timeout'. You should consider either expiring and/or testing
>> > connection validity before use in your application, increasing the server
>> > configured values for client timeouts, or using the Connector/J
>> connection
>> > property 'autoReconnect=true' to avoid this problem.
>> >
>> > I have searched a lot on net and added the following properties on
>> > hibernate.cfg.xml, as people there were suggesting this,but of no use.
>> > <!-- Sessions and transactions -->
>> > <!-- Use the C3P0 connection pool provider -->
>> > <property name="hibernate.c3p0.min_size">5</property>
>> > <property name="hibernate.c3p0.max_size">20</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="current_session_context_class">thread</property>
>> >
>> >
>> >
>> > Pl. help me.
>> > I have used hibernate3 with myeclipse as the development environment, and
>> am
>> > using mysql 5.x and centos (Linux) with Tomcat 5.x
>> > --
>>
>



-- 
Maurizio Cucchiara

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org