Java Tomcat 中的 JNDI:全局资源上的 BeanCreationException / NamingException。正在寻找与全局资源 returns 相同的 class

Java JNDI in Tomcat: BeanCreationException / NamingException on global Resource. Looking for the same class that global resource returns

我不明白什么会导致 Bean 创建异常代表 return 与所需的 class 相同。

class 是 com.mchange.v2.c3p0.ComboPooledDataSource,错误说 应该是 return [的一个实例com.mchange.v2.c3p0.ComboPooledDataSource] 但 returned [ 的实例com.mchange.v2.c3p0.ComboPooledDataSource]

这是错误:

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]

我正在使用 Java 7 和 Tomcat 7。

这是数据源的配置:

context.xml:

<ResourceLink name="jdbc/dataSourceGCA2"
  global="jdbc/dataSourceGCA2Global"
  auth="Container"
  type="com.mchange.v2.c3p0.ComboPooledDataSource" />

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" />

什么会导致这种行为?

感谢任何帮助。

(本来要发表评论的,但我的声望太低了)

这可能是由于两个不同的 classloader 加载了相同的 class。