-->
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.  [ 3 posts ] 
Author Message
 Post subject: c3p0: No suitable driver
PostPosted: Thu Jan 03, 2013 5:44 am 
Newbie

Joined: Mon Mar 12, 2012 2:27 pm
Posts: 4
Hello everybody. I found a very strange condtion: my application works on
development container but not on production container. On deployent container
I get the error "No suitable driver" from c3p0. Apparently (see logs below)
the driver is correctly configured by C3P0ConnectionProvider (who's
C3P0ConnectionProvider hibernate or c3p0?) but then gets lost (driverClass -> null)
in deployment environment only.

After 2 days in this issue, trying multiple possibilities, I am considering
debugging c3p0 to understand what's going on, but I would like to maka a last
check just to see this is not a trivial case.

1. The environment is basically the same. (Java 7, Tomcat 7, MySql 5)
2. The code is exectly the same (war)
3. If I connect stright to database with same URL everything works (but
there is no connection pool!)
4. I triple checked everything and I also tried to create a c3p0 configuration
file with driver name: nothing helps.


Any idea of what else can I check?

Thank you very much for any suggestion!!!


---- on development container (WORKS!) -----

Code:
07:40:25,562  INFO (Version.java:37) - HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
07:40:25,586  INFO (Version.java:41) - HHH000412: Hibernate Core {4.0.1.Final}
07:40:25,588  INFO (Environment.java:239) - HHH000206: hibernate.properties not found
07:40:25,589  INFO (Environment.java:342) - HHH000021: Bytecode provider name : javassist
07:40:25,612  INFO (Configuration.java:1956) - HHH000044: Configuring from URL: jndi:/localhost/ps.quotty/WEB-INF/hibernate.cfg.xml
07:40:25,642  WARN (DTDEntityResolver.java:74) - HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
07:40:25,677  INFO (Configuration.java:2061) - HHH000041: Configured SessionFactory: null
07:40:26,060  INFO (ConnectionProviderInitiator.java:186) - HHH000130: Instantiating explicit connection provider: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
07:40:26,071  INFO (C3P0ConnectionProvider.java:128) - HHH010002: C3P0 using driver:
    com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/quotty
   
    ^ *** CORRECTLY RECOGNIZED
   
    ?autoReconnect=true&useServerPrepStmts=false&jdbcCompliantTruncation=false
    &autoReconnect=true
07:40:26,071  INFO (C3P0ConnectionProvider.java:129) - HHH000046: Connection properties: {autoReconnect=true, user=quotty, password=****, autocommit=false}
07:40:26,071  INFO (C3P0ConnectionProvider.java:132) - HHH000006: Autocommit mode: false
07:40:26,083  INFO (MLog.java:80) - MLog clients using log4j logging.
07:40:26,136  INFO (C3P0Registry.java:204) - Initializing c3p0-0.9.1 [built 16-January-2007 14:46:42; debug? true; trace: 10]

07:40:26,214 INFO (AbstractPoolBackedDataSource.java:462) - Initializing c3p0
    pool... com.mchange.v2.c3p0.PoolBackedDataSource@cddd1e3d [
    connectionPoolDataSource ->
    com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@a90e6e0 [ acquireIncrement
    -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose
    -> false, automaticTestTable -> con_test, breakAfterAcquireFailure -> false,
    checkoutTimeout -> 30000, connectionCustomizerClassName -> null,
    connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester,
    debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null,
    forceIgnoreUnresolvedTransactions -> false, identityToken ->
    z8kfsx8r1ysikfulq8zsd|18726f1, idleConnectionTestPeriod -> 14400,
    initialPoolSize -> 10, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0,
    maxIdleTime -> 25200, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15,
    maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3,
    nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@c2107030 [
    description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation
                         
                         ^ *** AND KEPT!
                         
                       
    -> null, identityToken -> z8kfsx8r1ysikfulq8zsd|1ae4c6a, jdbcUrl ->
    jdbc:mysql://localhost:3306/quotty?autoReconnect=true&useServerPrepStmts=false&jdbcCompliantTruncation=false&autoReconnect=true,
    properties -> {autoReconnect=true, user=******, password=******,
    autocommit=false} ], preferredTestQuery -> select 1;, propertyCycle -> 0,
    testConnectionOnCheckin -> false, testConnectionOnCheckout -> false,
    unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false;
    userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null,
    identityToken -> z8kfsx8r1ysikfulq8zsd|5c2dce, numHelperThreads -> 3 ]

07:40:26,566  WARN (C3P0PooledConnectionPoolManager.java:701) - [class: com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager; method: createPooledConnectionPool()] [c3p0] Both automaticTestTable and preferredTestQuery have been set! Using automaticTestTable, and ignoring preferredTestQuery. Real test query is 'SELECT * FROM `con_test`'.
07:40:26,619  INFO (Dialect.java:121) - HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect

---- on deployment container ( DOES NOT WORK) -----
Code:
07:38:42,693  INFO (Version.java:37) - HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
07:38:42,713  INFO (Version.java:41) - HHH000412: Hibernate Core {4.0.1.Final}
07:38:42,718  INFO (Environment.java:239) - HHH000206: hibernate.properties not found
07:38:42,721  INFO (Environment.java:342) - HHH000021: Bytecode provider name : javassist
07:38:42,762  INFO (Configuration.java:1956) - HHH000044: Configuring from
    URL: jndi:/localhost/ps.quotty-1.0-SNAPSHOT/WEB-INF/hibernate.cfg.xml
07:38:42,803  WARN (DTDEntityResolver.java:74) - HHH000223: Recognized obsolete
    hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate
3.6 Migration Guide!
07:38:42,904  INFO (Configuration.java:2061) - HHH000041: Configured SessionFactory: null
07:38:43,784  INFO (ConnectionProviderInitiator.java:186) - HHH000130:
    Instantiating explicit connection provider: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
07:38:43,812  INFO (C3P0ConnectionProvider.java:128) - HHH010002: C3P0 using
    driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/quotty
   
    ^ *** SO APPARENTLY IT IS CORRECTLY CONFIGURED.
   
   
07:38:43,813  INFO (C3P0ConnectionProvider.java:129) - HHH000046: Connection
    properties: {autoReconnect=true, user=quotty, password=****, autocommit=false}
07:38:43,813  INFO (C3P0ConnectionProvider.java:132) - HHH000006: Autocommit mode: false
07:38:43,866  INFO (MLog.java:80) - MLog clients using log4j logging.
07:38:44,017  INFO (C3P0Registry.java:204) - Initializing c3p0-0.9.1
    [built 16-January-2007 14:46:42; debug? true; trace: 10]

07:38:44,300 INFO (AbstractPoolBackedDataSource.java:462) - Initializing c3p0
    pool... com.mchange.v2.c3p0.PoolBackedDataSource@a4b0e925 [
    connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoo
    lDataSource@c2c8035e [ acquireIncrement -> 3, acquireRetryAttempts -> 30,
    acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable ->
    null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0,
    connectionCustomizerClassName -> null, connectionTesterClassName ->
    com.mchange.v2.c3p0.impl.DefaultConnectionTester,
    debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null,
    force IgnoreUnresolvedTransactions -> false, identityToken ->
    k8xj308r1yuljdc1ls7nri|18ba0a, idleConnectionTestPeriod -> 14400,
    initialPoolSize -> 3, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0,
    maxIdleT ime -> 25200, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15,
    maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3,
    nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@97ea44f1 [
    description -> null, driverClass -> null, factoryClassLocation -> null,
   
                         ^ *** AND HEN GETS NULL!
   
    identityToken -> k8xj308r1yuljdc1ls7nri|17bfb33, jdbcUrl ->
    jdbc:mysql://localhost:3306/quotty, properties -> {autoReconnect=true,
    user=******, password=******, autocommit=false} ], preferredTestQuery -> select
    1;, propertyCycle -> 0, testConnectionOnCheckin -> false,
    testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0,
    usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName
    -> null, factoryClassLocation -> null, identityToken ->
    k8xj308r1yuljdc1ls7nri|114cbc4, numHelperThreads -> 3 ]

07:39:13,620 WARN (BasicResourcePool.java:1841) -
    com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@da9e38 -- Acquisition
    Attempt Failed!!! Clearing pending acquires. While trying to acquire a neede d
    new resource, we failed to succeed more than the maximum number of allowed
    acquisition attempts (30). Last acquisition attempt exception:
    java.sql.SQLException: No suitable driver
   

------ HIBERNATE CONFIGURATION -----
Code:
<!DOCTYPE hibernate-configuration SYSTEM
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
   
  <!-- connection -->

    <!-- the table to be deleted to fully rebuild database -->   
    <property name="net.cbsolution.scc.hbn.HibernateUtil.checkTable">KeywordEntry</property>

    <!-- MYSQL connection -->
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/quotty?autoReconnect=true&amp;useServerPrepStmts=false&amp;jdbcCompliantTruncation=false&amp;autoReconnect=true</property>
   
    <property name="hibernate.connection.username">quotty</property>
    <property name="hibernate.connection.password">****</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
    <property name="hibernate.connection.autocommit">false</property >
    <property name="hibernate.connection.autoReconnect">true</property>     
    <property name="show_sql">false</property>
    <property name="format_sql">true</property>
    <property name="current_session_context_class">thread</property>

    <property name="hibernate.hbm2ddl.auto">validate</property>


    <property name="hibernate.connection.autoReconnect">true</property>     

   <property name="hibernate.c3p0.acquire_increment">3</property>
   <property name="hibernate.c3p0.idle_test_period">14400</property>
   <property name="hibernate.c3p0.timeout">25200</property>
   <property name="hibernate.c3p0.max_size">15</property>
   <property name="hibernate.c3p0.min_size">3</property>
   <property name="hibernate.c3p0.max_statements">0</property>
   <property name="hibernate.c3p0.preferredTestQuery">select 1;</property>
   <property name="driverClass">com.mysql.jdbc.Driver</property>
     
   
    <!-- List of mapped classes -->
    <mapping class="net.cbsolution.ps.quotty.domain.User"/>
    ...
  </session-factory>
 
</hibernate-configuration>
 


Top
 Profile  
 
 Post subject: Re: c3p0: No suitable driver
PostPosted: Thu Jan 03, 2013 7:17 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Did you try with specifying the connection provider class explictly?

<property name="hibernate.connection.provider_class" value="org.hibernate.service.jdbc.connections.internal .C3P0ConnectionProvider"/>


Top
 Profile  
 
 Post subject: Re: c3p0: No suitable driver
PostPosted: Thu Jan 03, 2013 9:09 am 
Newbie

Joined: Mon Mar 12, 2012 2:27 pm
Posts: 4
Thank you very much indeed pb00067!!!

I added to my config:

Code:
<property name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property>


And now the application connects properly. What is curious is that nowhere is stated that connection provided shall be defined (and no example show it).

You made my day.

Thanks again.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.