I don't understand what can cause a Bean creation exception on behalf to return the same class as required.
The class is com.mchange.v2.c3p0.ComboPooledDataSource
, and the error says that was expected to return an instance of [com.mchange.v2.c3p0.ComboPooledDataSource] but returned an instance of [com.mchange.v2.c3p0.ComboPooledDataSource]
This is the error:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSourceGCA' defined in class path resource [META-INF/xxxxx-security-app.xml]:
Invocation of init method failed; nested exception is javax.naming.NamingException:
The local resource link [dataSourceGCA2] that refers to global resource [jdbc/dataSourceGCA2Global] was expected to return an instance of [com.mchange.v2.c3p0.ComboPooledDataSource] but returned an instance of [com.mchange.v2.c3p0.ComboPooledDataSource]
I'm using Java 7 and Tomcat 7.
This is the config of datasource:
In context.xml:
<ResourceLink name="jdbc/dataSourceGCA2"
global="jdbc/dataSourceGCA2Global"
auth="Container"
type="com.mchange.v2.c3p0.ComboPooledDataSource" />
In server.xml:
<Resource description="whatever"
name="jdbc/dataSourceGCA2Global"
auth="Container"
factory="org.apache.naming.factory.BeanFactory"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
user="xxxxxxxx"
password="xxxxxxxx"
initialPoolSize="1"
minPoolSize="1"
maxPoolSize="5"
acquireIncrement="1"
driverClass="oracle.jdbc.driver.OracleDriver"
jdbcUrl="jdbc:oracle:thin:@tprodva2:1522/BD2"
testConnectionOnCheckin="true"
idleConnectionTestPeriod="300"
maxIdleTimeExcessConnections="0"
maxIdleTime="0" />
What can cause this behaviour?
Any help is appreciated.
(was gonna comment but I have too little reputation)
This can be caused by the same class being loaded by two different classloaders.