gpt4 book ai didi

Tomcat 中的 Java JNDI : BeanCreationException/NamingException on global Resource. 寻找全局资源返回的相同类

转载 作者:行者123 更新时间:2023-12-01 17:52:30 24 4
gpt4 key购买 nike

我不明白什么会导致 Bean 创建异常代表返回所需的相同类。

该类是com.mchange.v2.c3p0.ComboPooledDataSource,错误表明预计返回 [com .mchange.v2.c3p0.ComboPooledDataSource],但返回 [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" />

什么会导致这种行为?

感谢任何帮助。

最佳答案

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

这可能是由两个不同的类加载器加载同一个类引起的。

关于Tomcat 中的 Java JNDI : BeanCreationException/NamingException on global Resource. 寻找全局资源返回的相同类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48460885/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com