-->
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.  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Hibernate dont' respond!
PostPosted: Sat Feb 05, 2011 11:34 am 
Newbie

Joined: Sat Feb 05, 2011 11:27 am
Posts: 14
Hi,
I deployed a project on a linux server with mysql 5.0.51 + tomcat 6.0.18. Here there is also another project with hibernate 3.3 that works fine.
This new project I deployed has hibernate 3.5.6 final. After deploy the query to db works fine, but after some time it don't work and the client waiting for server hibernate response that don't come back!
Seems that Hibernate remains blocked:
This is the DEBUG on the server:
Code:
05/02/2011 16:23:02 DEBUG BasicResourcePool:548 - acquire test -- pool is already maxed out. [managed: 10; max: 10]
05/02/2011 16:23:02 DEBUG BasicResourcePool:1279 - awaitAvailable(): com.mchange.v2.c3p0.impl.NewPooledConnection@7301061
05/02/2011 16:23:02 DEBUG BasicResourcePool:1620 - trace com.mchange.v2.resourcepool.BasicResourcePool@6a74f160 [managed: 10, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@7301061)


After the last line I don't see anything! Neither a timeout exception or some similar. So I think this is not the 8 hours problems with Mysql.

Any ideas?

Thanks vey much

Best regards


Top
 Profile  
 
 Post subject: Re: Hibernate dont' respond!
PostPosted: Wed Feb 09, 2011 4:39 am 
Newbie

Joined: Sat Feb 05, 2011 11:27 am
Posts: 14
Another info: if I restart Tomcat the hibernate's query works for some hours. After this time any request seems stuck!!!


help please!!

Thanks


Top
 Profile  
 
 Post subject: Re: Hibernate dont' respond!
PostPosted: Wed Feb 09, 2011 5:33 am 
Regular
Regular

Joined: Fri Jan 28, 2011 11:44 am
Posts: 117
Quote:
pool is already maxed out. [managed: 10; max: 10]


All your pool connections are already taken ... you need to free them once you finished using them!


Top
 Profile  
 
 Post subject: Re: Hibernate dont' respond!
PostPosted: Wed Feb 09, 2011 5:41 am 
Newbie

Joined: Sat Feb 05, 2011 11:27 am
Posts: 14
Hi,
when I use Hibernate every query is similar to this:
Code:
try{
session = MyHibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
List<Cliente> listaClientiVoip = ClienteDao.listAllCliVoip(session);
session.flush();
session.getTransaction().commit();
catch (Exception ex) {
         log.error("", ex);
         try {
            if (session != null && session.getTransaction() != null) {
               session.getTransaction().rollback();
            }
         } catch (RuntimeException rbEx) {
            log.error("Non riesco ad annullare la transazione.", rbEx);
         }
      }

So I think when I commit the transaction the connection is free. Where is my mistake?

Thanks!


Top
 Profile  
 
 Post subject: Re: Hibernate dont' respond!
PostPosted: Wed Feb 09, 2011 6:08 am 
Regular
Regular

Joined: Fri Jan 28, 2011 11:44 am
Posts: 117
You need to close the session ...
You can add session.close() in the finally clause of your try/catch


Top
 Profile  
 
 Post subject: Re: Hibernate dont' respond!
PostPosted: Wed Feb 09, 2011 6:55 am 
Newbie

Joined: Sat Feb 05, 2011 11:27 am
Posts: 14
Hi,
I'm using SessionFactory and the method getCurrentSession() that should flush and close automatically the session.
In fact if I try to close the session in my code I've this exception:

Code:
Caused by: org.hibernate.SessionException: Session was already closed
at org.hibernate.impl.SessionImpl.close(SessionImpl.java:312)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


Thanks


Top
 Profile  
 
 Post subject: Re: Hibernate dont' respond!
PostPosted: Wed Feb 09, 2011 7:05 am 
Regular
Regular

Joined: Fri Jan 28, 2011 11:44 am
Posts: 117
Oh sorry, I'm so used to openSession() that I didn't even notice that you were using the other solution: getCurrentSession() ...
Can you post your hibernate.cfg.xml file ?


Top
 Profile  
 
 Post subject: Re: Hibernate dont' respond!
PostPosted: Wed Feb 09, 2011 7:10 am 
Newbie

Joined: Sat Feb 05, 2011 11:27 am
Posts: 14
This is my hibernate.conf

Code:
<!DOCTYPE hibernate-configuration PUBLIC '-//Hibernate/Hibernate Configuration DTD 3.0//EN' 'http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd'>
<hibernate-configuration>
   <session-factory>
      <!-- Database connection settings -->
      <!-- MySQL -->
      <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
      <property name="connection.url">jdbc:mysql://192.168.185.254:3306/ztl_import</property>
      <property name="connection.autoReconnect">true</property>
      <property name="connection.autoReconnectForPools">true</property>
      <property name="connection.is-connection-validation-required">true</property>
      <property name="connection.username">root</property>
      <property name="connection.password">xxxxxxxx</property>

      <!--
         per usare true e false nelle query: togliere se il db non è mysql
      -->
      <property name="hibernate.query.substitutions">true 1, false 0</property>
      <!--
         <property name="hibernate.connection.tinyInt1isBit">true</property>
         <property
         name="hibernate.connection.transformedBitIsBoolean">true</property>
      -->



      <!-- JDBC connection pool (use the built-in) -->
      <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
      <property name="c3p0.acquire_increment">1</property>
      <property name="c3p0.idle_test_period">14400</property>
      <property name="c3p0.max_size">10</property>
      <property name="c3p0.max_statements">0</property>
      <property name="c3p0.min_size">10</property>
      <property name="c3p0.timeout">25200</property>
      <property name="connection.pool_size">20</property>

      <!-- SQL dialect -->
      <!--
         <property
         name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
      -->
      <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>

      <!-- Enable Hibernate's automatic session context management -->
      <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
      <property name="current_session_context_class">thread</property>

      <!-- Disable the second-level cache  -->
      <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
      <property name="hibernate.cache.use_query_cache">false</property>

      <!-- Echo all executed SQL to stdout -->
      <property name="show_sql">true</property>
      <property name="format_sql">true</property>
      <property name="use_sql_comments">true</property>

      <property name="hbm2ddl.auto">update</property>
   
                <!--HERE THERE ARE ALL MAPPINGS-->
      <mapping class="xxxxxx" />
   
      
   </session-factory>

</hibernate-configuration>


Top
 Profile  
 
 Post subject: Re: Hibernate dont' respond!
PostPosted: Wed Feb 09, 2011 9:03 am 
Newbie

Joined: Wed Jan 26, 2011 12:32 pm
Posts: 12
Just try with factory.opensession and close at the end


Top
 Profile  
 
 Post subject: Re: Hibernate dont' respond!
PostPosted: Wed Feb 09, 2011 9:12 am 
Newbie

Joined: Sat Feb 05, 2011 11:27 am
Posts: 14
Hi injrav,do you think the problem can be that? This project on my development machine works fine without problem.

I could be modify all project using openSession but there are hundred calls of this type. Other projects with the same code structure works fine.

I can't understand the cause of this problem!

Thanks!


Top
 Profile  
 
 Post subject: Re: Hibernate dont' respond!
PostPosted: Wed Feb 09, 2011 9:36 am 
Regular
Regular

Joined: Fri Jan 28, 2011 11:44 am
Posts: 117
injrav wrote:
Just try with factory.opensession and close at the end


That's not a solution, you're just avoiding the problem!

@drenda
At first sight I don't see anything wrong in your configuration file ... the values of c3p0.idle_test_period and c3p0.timeout seem really big to me but that shoudn't cause you this kind of problem ...
Is your project using multiple threads?


Top
 Profile  
 
 Post subject: Re: Hibernate dont' respond!
PostPosted: Wed Feb 09, 2011 9:53 am 
Newbie

Joined: Sat Feb 05, 2011 11:27 am
Posts: 14
Hi overmeulen,
ok I'll test the application with openSession().

I'm using multiple threads in my application. There are some scheduler that made some queries on db.

Daniele


Top
 Profile  
 
 Post subject: Re: Hibernate dont' respond!
PostPosted: Wed Feb 09, 2011 10:06 am 
Regular
Regular

Joined: Fri Jan 28, 2011 11:44 am
Posts: 117
Hi,

I did not tell you to test openSession(), I even said that it was a bad solution in your case ^^

If you have multiple threads then maybe your problem comes from that!
If I remember well how getCurrentSession() works, it will create 1 session per thread trying to access the database because the "current" session is bound to the thread (<property name="current_session_context_class">thread</property>).
So if you have more than 10 (<property name="c3p0.max_size">10</property>) threads accessing the database at the same time then you will have a problem ...


Top
 Profile  
 
 Post subject: Re: Hibernate dont' respond!
PostPosted: Wed Feb 09, 2011 10:35 am 
Newbie

Joined: Sat Feb 05, 2011 11:27 am
Posts: 14
Hi overmeulen,
sorry I read it wrong. Thanks for your explanations. With your suggestion I found an error on a thread that didn't commit the transaction.

Thanks!!!

Daniele


Top
 Profile  
 
 Post subject: Re: Hibernate dont' respond!
PostPosted: Wed Feb 09, 2011 10:38 am 
Regular
Regular

Joined: Fri Jan 28, 2011 11:44 am
Posts: 117
Did it fix your pool connection problem?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next

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.