我正在尝试将 removeAbandoned 属性添加到运行 Tomcat 5.5 的环境中的资源。 在添加此属性之前,在此环境中运行的 servlet 工作正常。 一旦我添加属性,就会抛出异常,如下所示:
EXCEPTION javax.naming.NamingException:找不到属性的设置方法:removeAbandoned。
我不明白为什么会发生这种情况。 一旦我删除了该属性,servlet 就会再次工作。
下面是在我的环境中显示的整个上下文标记:
<Context path="/emscribe" docBase="emscribe" debug="0" reloadable="true"
crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="emscribe_log."
suffix=".txt" timestamp="true"/>
<Resource name="jdbc/emscribe" auth="Container"
type="com.mchange.v2.c3p0.ComboPooledDataSource" driverClass="com.mysql.jdbc.Driver"
maxPoolSize="100" minPoolSize="5"
acquireIncrement="5" removeAbandoned="true"
user="aUserID"
password="aPassword"
factory="org.apache.naming.factory.BeanFactory"
jdbcUrl="jdbc:mysql://127.000.71.101/emscribedx?autoReconnect=true"
/>
您的例外:
javax.naming.NamingException: No set method found for property: removeAbandoned.
声明它找不到从资源中指定的类型getRemoveAbandoned()
和setRemoveAbandoned(boolean removeAbandoned)
的方法。
removeAdandoned
属性只能与 Apache DBCP BasicDataSource 一起使用。
因此,您的资源jdbc/emscribe
类型不能是com.mchange.v2.c3p0.ComboPooledDataSource
,而是org.apache.commons.dbcp.BasicDataSource
。
希望这有帮助。
removeAdandoned 不适用于 cp30 连接池。它适用于旧 tomcat 版本上的 DBCP 或 tomcat 7 中引入的 apache 连接池