NullPointerException Using C3P0 with Hibernate on Jetty

View: New views
1 Messages — Rating Filter:   Alert me  

NullPointerException Using C3P0 with Hibernate on Jetty

by neilac333 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am using the following:

Hibernate 3.2.6
C3P0 0.9.1.2
Jetty 6.1.11
OJDBC 6 (hitting an Oracle database)

When I deploy my web application to Jetty, I get the following:

17 Sep 2009 16:31:21,765: INFO  com.mchange.v2.c3p0.C3P0Registry.banner - Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
17 Sep 2009 16:31:21,781: DEBUG com.mchange.v2.c3p0.management.DynamicPooledDataSourceManagerMBean.reinitialize - MBean: com.mchange.v2.c3p0:type=PooledDataSource[2sa1mf831jyqtyw1wehs7c|50988] registered.
17 Sep 2009 16:31:21,843: DEBUG com.mchange.v2.resourcepool.BasicResourcePool.incrementPendingAcquires - incremented pending_acquires: 1
17 Sep 2009 16:31:21,843: DEBUG com.mchange.v2.resourcepool.BasicResourcePool.incrementPendingAcquires - incremented pending_acquires: 2
17 Sep 2009 16:31:21,843: DEBUG com.mchange.v2.resourcepool.BasicResourcePool.incrementPendingAcquires - incremented pending_acquires: 3
17 Sep 2009 16:31:21,843: DEBUG com.mchange.v2.resourcepool.BasicResourcePool.<init> - com.mchange.v2.resourcepool.BasicResourcePool@1402d5a config: [start -> 3; min -> 3; max -> 15; inc -> 3; num_acq_attempts -> 30; acq_attempt_delay -> 1000; check_idle_resources_delay -> 0; mox_resource_age -> 0; max_idle_time -> 0; excess_max_idle_time -> 0; destroy_unreturned_resc_time -> 0; expiration_enforcement_delay -> 0; break_on_acquisition_failure -> false; debug_store_checkout_exceptions -> false]
17 Sep 2009 16:31:21,859: DEBUG com.mchange.v2.resourcepool.BasicResourcePool.run - An exception occurred while acquiring a poolable resource. Will retry.
java.lang.NullPointerException
   at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(Unknown Source)
   at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(Unknown Source)
   at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(Unknown Source)
   at java.sql.DriverManager.getDriver(Unknown Source)
   at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:223)
   at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:119)
   at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:143)
   at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:132)
   at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
   at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
   at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
   at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
   at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)


-------------------------


Here is my configuration of my datasource in Jetty:

<New id="myDataSource" class="org.mortbay.jetty.plus.naming.Resource">
        <Arg>MY_DS</Arg> <!-- jndi name -->
        <Arg>
            <New class="com.mchange.v2.c3p0.ComboPooledDataSource">
                <Set name="driverClass">oracle.jdbc.OracleDriver</Set>
                <Set name="jdbcUrl">url</Set>
                <Set name="user">user</Set>
                <Set name="password">pwd</Set>
                <Set name="minPoolSize">1</Set>
                <Set name="acquireIncrement">1</Set>
                <Set name="maxPoolSize">10</Set>
                <Set name="idleConnectionTestPeriod">300</Set>
                <Set name="checkoutTimeout">0</Set>
                <Set name="maxStatementsPerConnection">50</Set>
            </New>
        </Arg>
    </New>


-------------------------------------

Finally, my persistence.xml file:

<persistence-unit name="myPersistenceUnit" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>MY_DS</jta-data-source>
        <class>com.myapp.MyClass</class>
        <properties>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.format_sql" value="true"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
            <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
            <property name="hibernate.c3p0.min_size" value="1"/>
            <property name="hibernate.c3p0.max_size" value="10"/>
            <property name="hibernate.c3p0.timeout" value="0"/>
            <property name="hibernate.c3p0.max_statements" value="50"/>
            <property name="hibernate.c3p0.acquire_increment" value="1"/>
            <property name="hibernate.c3p0.idle_test_period" value="300"/>
        </properties>
    </persistence-unit>

-------------------------------------

I have the Oracle driver and C3P0 in the classpath.

This error has been driving me nuts for a while, so any insight is really appreciated.

Thanks.