我正在將一個Web應用程序(WAR)部署到Tomcat 8 Web容器。在Tomcat 8上使用jTDS JDBC驅動程序的AbstractMethodError
戰爭在 '/ WEB-INF/lib' 目錄下包括以下JTDS JDBC驅動:
<dependency org="net.sourceforge.jtds" name="jtds" rev="1.3.1" />
(文件是:jtds-1.3.1.jar
)。
這是資源如何在META-INF/context.xml
定義:
<Resource name="jdbc/jtds/sybase/somedb"
auth="Container"
type="javax.sql.DataSource"
driverClassName="net.sourceforge.jtds.jdbc.Driver"
url="jdbc:jtds:sybase://localhost:2501/somedb"
username="someuser" password="somepassword"
/>
在我的代碼獲得javax.sql.DataSource正常方式:
InitialContext cxt = new InitialContext();
if (cxt == null) {
throw new RuntimeException("Uh oh -- no context!");
}
DataSource ds = (DataSource) cxt.lookup(lookupName);
我進一步驗證(通過印刷),該數據源對象ds
屬於預期類型:
org.apache.tomcat.dbcp.dbcp2.BasicDataSource
&hellip;但是當我試圖從中得到一個連接:
Connection conn = ds.getConnection();
&hellip;我得到以下跟蹤:
java.lang.AbstractMethodError
net.sourceforge.jtds.jdbc.JtdsConnection.isValid(JtdsConnection.java:2833)
org.apache.tomcat.dbcp.dbcp2.DelegatingConnection.isValid(DelegatingConnection.java:924)
org.apache.tomcat.dbcp.dbcp2.PoolableConnection.validate(PoolableConnection.java:282)
org.apache.tomcat.dbcp.dbcp2.PoolableConnectionFactory.validateConnection(PoolableConnectionFactory.java:359)
org.apache.tomcat.dbcp.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:2316)
org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2299)
org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2043)
org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1543)
什麼給?