Wednesday, January 19, 2011

[SOLVED] P6DriverNotFoundError: Error registering factory


Caused by: com.p6spy.engine.spy.P6DriverNotFoundError:
Error registering factory [com.p6spy.engine.logging.P6LogFactory]
Caused By: java.lang.ClassCastException: com.p6spy.engine.logging.P6LogFactory
cannot be cast to com.p6spy.engine.spy.P6Factory
at com.p6spy.engine.spy.P6SpyDriverCore.initMethod(
at com.p6spy.engine.spy.P6SpyDriver.initMethod(
at com.p6spy.engine.spy.P6SpyDriver.(
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory


This problem is caused when I have multiple copies of p6spy.jar (one in my WAR file and the other one in Tomcat Lib folder). There should be only one copy of the jar per class loader. By removing p6spy.jar from either the war file or tomcat lib, problem is gone.