2013-04-25 130 views
0

我在嘗試部署我的WAR應用程序時遇到此錯誤。無法創建用於連接url的'''jdbc驅動程序'null'postgresql

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> 

有人有一些想法,爲什麼不工作? 任何建議將受到歡迎! 在此先感謝!

回答

0

什麼是您的文件aKS.xml

如果要指定您的應用程序之外在Tomcat中的WAR數據源,您必須配置在context.xml,例如:

<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" 
       maxActive="100" maxIdle="30" maxWait="10000" 
       username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver" 
       url="jdbc:mysql://localhost:3306/javatest"/> 

(從Tomcat的JNDI Datasource HOW-TO服用。)

相關問題