当我尝试部署我的 WAR 应用程序时出现此错误。
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of cla
ss '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(B
asicDataSource.java:1452)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDat
aSource.java:1371)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSo
urce.java:1044)
at kimet.ConexionSQL.getConexion(ConexionSQL.java:20)
at kimet.Global.cargarHashtablesAux(Global.java:2360)
at kimet.Inicio.init(Inicio.java:33)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:1206)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:10
26)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
t.java:4421)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
734)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
9)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778
)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504
)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463
)
at org.apache.catalina.core.StandardService.start(StandardService.java:5
25)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754
)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(B
asicDataSource.java:1437)
... 31 more
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of cla
ss '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(B
asicDataSource.java:1452)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDat
aSource.java:1371)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSo
urce.java:1044)
at kimet.ConexionSQL.getConexion(ConexionSQL.java:20)
at kimet.Global.cargarHashtablesAux(Global.java:2360)
at kimet.Inicio.init(Inicio.java:33)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:1206)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:10
26)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
t.java:4421)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
734)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
9)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778
)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504
)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463
)
at org.apache.catalina.core.StandardService.start(StandardService.java:5
25)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754
)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(B
asicDataSource.java:1437)
... 31 more
--- Inicializado KimetSport --- Thu Apr 25 11:16:13 CEST 2013
25-abr-2013 11:16:13 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Despliegue del directorio docs de la aplicaci¾n web
25-abr-2013 11:16:13 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Despliegue del directorio examples de la aplicaci¾n web
25-abr-2013 11:16:14 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Despliegue del directorio ROOT de la aplicaci¾n web
25-abr-2013 11:16:14 org.apache.coyote.http11.Http11AprProtocol start
INFO: Arrancando Coyote HTTP/1.1 en puerto http-8080
25-abr-2013 11:16:14 org.apache.coyote.ajp.AjpAprProtocol start
INFO: Arrancando Coyote AJP/1.3 en ajp-8009
25-abr-2013 11:16:14 org.apache.catalina.startup.Catalina start
INFO: Server startup in 4540 ms
我给你看我修改过的文件:
一开始,在Tomcat的context.xml文件中:
<Context reloadable="true" privileged="true">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
在 web.xml 文件中:
<resource-ref>
<!-- <description>DB Kimet</description> -->
<res-ref-name>modulo/KIMET</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<!-- <res-sharing-scope>Shareable</res-sharing-scope> -->
</resource-ref>
最后,我在“conf\Catalina\localhost”目录中创建了自己的 xml 文件“aKS.xml”
<?xml version='1.0' encoding='utf-8'?>
<Context crossContext="true" displayName="Kimet Sport" docBase="C:/Workarea/kimetsportweb/WebContent" path="/aKS" reloadable="true">
<Resource name="modulo/KIMET"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
defaultAutoCommit="false"
removeAbandoned="false"
removeAbandonedTimeout="30"
maxActive="50"
maxIdle="20"
maxWait="10000"
username="usukimet"
password="usukimet"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://192.168.1.169:5432/kimet_desarrollo"/>
</Context>
有人知道为什么不工作吗?任何建议都将受到欢迎!提前致谢!