I am trying to use C3P0 connection pool in my persitence.xml file in wildfly 20 which uses hibernate 5.3.17
Connections in C3P0 fails with following error:
2020-09-24 12:01:20,344 WARN [com.mchange.v2.resourcepool.BasicResourcePool] (C3P0PooledConnectionPoolManager[identityToken->1hge13bac1gxr25d15hy3l7|767aa393]HelperThread#0) com.mchange.v2.resourcepool.BasicR
esourcePool$ScatteredAcquireTask@84b4ffa – Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed ac
quisition attempts (30). Last acquisition attempt exception: : java.lang.NullPointerException
The reason of the error is that hibernate removes hibernate.connection.url and hibernate.connection.driver_class from properties when it detect a datasource configured. Eventhough I have not configured any datasource in my persistence.xml wildfly is substituting a default datasource and that is causing hibernate to remove the above properties and thus the failure occurs. My persistence.xml is:
The reason for using C3P0 Connection pool is performance gain. We were using it with wildfly 10 for performance gain. Now I am migrating it to wildfly 20. Wildfly 20 comes with hibernate 5.3.17 which removes hibernate.connection.url and hibernate.connection.driver_class from properties when it detects a datasource. What is aim of removing these properties?
Ok, thanks for the context. I’m not sure why the properties are being removed, we’ll have a look.
I’m surprised though that C3P0 would perform better. Did you measure this accurately? I suppose that it’s possible in specific configuration and contexts, but just to let you know: in our test the WildFly datasource is generally better for performance; it’s also integrated with other subsystems (statistics, security, transactionmanager to mention a few), so I wonder if you’re seeing better performance because you don’t need such integrations (which you could also disable if that’s the case?) , or if you’re possibly running your system unintentionally without such useful aspects.
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl line 899 of hibernate 5.3.17 contains following code
With regard to WildFly 10, are you sure that the C3P0 connection pool was actually being used?
Is your application written to use Java EE features like EJB + JTA Transaction management? Or is your application not using those parts of WildFly?
<property name="wildfly.jpa.allowdefaultdatasourceuse" value="false" />