Reputation: 745
using tomcat 7, tomcat-jdbc.jar, p6spy 2.14, C3p0, and hibernate on ubuntu 14.04 OS.
my p6spy.jar resides in /usr/share/tomcat7/lib which is in my cp. spy.properties file is being passed in via system property to tomcat properly.
Relevant section of hibernate.cfg.xml
<hibernate-config>
<driver_class>com.p6spy.engine.spy.P6SpyDriver</driver_class>
<url>jdbc:p6spy:mysql://myhost:3306/mydatabase</url>
<username>xxx</username>
<password>xxx</password>
</hibernate-config>
when i explicitly add driverlist=com.mysql.jdbc.Driver
to the spy.properties tomcat throws this exception:
Warning: Error registering driver names: [com.mysql.jdbc.Driver]
Caused By: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
com.p6spy.engine.spy.P6DriverNotFoundError: Error registering driver names: [com.mysql.jdbc.Driver]
Caused By: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at com.p6spy.engine.spy.P6ModuleManager.loadDriversExplicitly(P6ModuleManager.java:220)
at com.p6spy.engine.spy.P6ModuleManager.<init>(P6ModuleManager.java:130)
at com.p6spy.engine.spy.P6ModuleManager.initMe(P6ModuleManager.java:73)
at com.p6spy.engine.spy.P6ModuleManager.<clinit>(P6ModuleManager.java:61)...
When i rem out the driverlist setting - or put it in like above i always get this exception - oddly lloking like the p6spy prefix was truncated off my connection string:
WARN [com.mchange.v2.resourcepool.BasicResourcePool]: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@309efc1f -- 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 acquisition attempts (30). Last acquisition attempt exception:
java.sql.SQLException: Unable to find a driver that accepts jdbc:mysql://devtestrds.cdsug1b8degu.us-west-1.rds.amazonaws.com:3306/biz_eng
at com.p6spy.engine.spy.P6SpyDriver.findPassthru(P6SpyDriver.java:119)
at com.p6spy.engine.spy.P6SpyDriver.connect(P6SpyDriver.java:94)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
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)
im at a loss as to why p6spy wont find this driver. Could this be some kind of class loading error perhaps? any clues appreciated
Upvotes: 1
Views: 5638
Reputation: 4096
Going crazy today while facing this issue. Scrolling up my log, I realize that my ojdbc driver was not supported by Java 6. Configuring Java 7 and everything goes well.
Upvotes: 0
Reputation: 848
With P6Spy 2.X, you will need to set driverlist=com.mysql.jdbc.Driver in spy.properties.
P6Spy 1.3 would automatically register drivers which sometimes caused duplicate registration. This is why 1.3 also had the setting to deregister drivers.
Upvotes: 2
Reputation: 745
After adding mysql-connector-java-5.1.37-bin.jar to my CP i was able to get tomcat to find a sql driver via the p6spy driver passthrough - but then i ended up throwing a linkage exception.
I did eventually however get p6spy running correctly on my tomcat7/hibernate config by downgrading to p6spy v1.3 and setting "deregisterdrivers=true" in the corresponding 1.3 format spy.properties file.
Upvotes: 0