Thread: Same old story :( "Cannot load JDBC driver class 'null'"
Hi all, first of all, sorry for this long mail, but i´m working on this problem since 4 days. And i really need help. I read a lot of websites about this problem but i still can't fix my problem so i hope you could help me. Thank you very much. Every time i try to connect the postgresql-Database with my little JSP (running in Tomcat) i got this Error: --> java.sql.SQLException: Cannot load JDBC driver class 'null' <-- my environment ----------------------------------------------- PostgreDB and Tomcat are running on the same Server. - the DB is named "mze" - the user for this DB is named also "mze" - the user has no password for the DB so it's "" my Tomcat version 4.1.18 my Tomcat is listening on Port 4444 my Tomcat-Directory is: /opt/jakarta/tomcat the Environment varibabl is: CATALINA_HOME=/opt/jakarta/tomcat the Name of my Webapplication is: %CATALINA_HOME%/webapps/Timerecording my jsp is lying in: %CATALINA_HOME%/webapps/Timerecording/WEB-INF/jsp my javaclass is lying in: %CATALINA_HOME%/webapps/Timerecording/WEB-INF/src the JDBC-Driver "pg73jdbc3.jar is lying in: %CATALINA_HOME%/common/lib ----------------------------------------------- web.xml of my webapp: ----------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <servlet>....</servlet> <servlet-mapping>....</servlet-mapping> <resource-ref> <description>postgreSQL Connection</description> <res-ref-name>jdbc/mze</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </web-app> ----------------------------------------------- javaclass of my webapp ----------------------------------------------- public class Order { String connectionState = "Not Connected"; public void init() throws Exception { DataSource ds=null; Connection conn=null; Context ctx = new InitialContext(); ds = (DataSource) ctx.lookup("java:comp/env/jdbc/mze"); try{ conn = ds.getConnection(); //<----------------EXCEPTION HERE } catch(Exception e){ throw new Exception("Boom - No Connection -->"+e); } try { if (conn != null) { ... conn.close(); } } catch (Exception e) {throw new Exception(" conn == null -->" + e); } } ----------------------------------------------- server.xml of my tomcat (sorry i don´t know what is important to fix my problem.So it´s very long! Sorry! the most important is at the tail of this file): ----------------------------------------------- <Server port="8005" shutdown="SHUTDOWN" debug="0"> <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" debug="0"/> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" debug="0"/> <GlobalNamingResources> <Environment name="simpleValue" type="java.lang.Integer" value="30"/> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved"></Resource> <ResourceParams name="UserDatabase"> <parameter> <name>factory</name> <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value> </parameter> <parameter> <name>pathname</name> <value>conf/tomcat-users.xml</value> </parameter> </ResourceParams> </GlobalNamingResources> <Service name="Tomcat-Standalone"> <!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 --> <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="4444" minProcessors="5" maxProcessors="75" enableLookups="true" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" useURIValidationHack="false" disableUploadTimeout="true" /> <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 --> <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8009" minProcessors="5" maxProcessors="75" enableLookups="true" redirectPort="8443" acceptCount="10" debug="0" connectionTimeout="0" useURIValidationHack="false" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/> <!-- Define the top level container in our container hierarchy --> <Engine name="Standalone" defaultHost="localhost" debug="0"> <!-- Global logger unless overridden at lower levels --> <Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/> <!-- Because this Realm is here, an instance will be shared globally --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" debug="0" resourceName="UserDatabase"/> <!-- Define the default virtual host --> <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true"/> <!-- Tomcat Examples Context --> <Context path="/examples" docBase="examples" debug="0" reloadable="true" crossContext="true"> <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_examples_log." suffix=".txt" timestamp="true"/> <Ejb name="ejb/EmplRecord" type="Entity" home="com.wombat.empl.EmployeeRecordHome" remote="com.wombat.empl.EmployeeRecord"/> <Environment name="maxExemptions" type="java.lang.Integer" value="15"/> <Parameter name="context.param.name" value="context.param.value" override="false"/> <Resource name="jdbc/EmployeeAppDb" auth="SERVLET" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/EmployeeAppDb"> <parameter><name>username</name><value>sa</value></parameter> <parameter><name>password</name><value></value></parameter> <parameter><name>driverClassName</name><value>org.hsql.jdbcDriver</value></parameter> <parameter><name>url</name><value>jdbc:HypersonicSQL:database</value></parameter> </ResourceParams> <Resource name="mail/Session" auth="Container" type="javax.mail.Session"/> <ResourceParams name="mail/Session"> <parameter><name>mail.smtp.host</name><value>localhost</value></parameter> </ResourceParams> <ResourceLink name="linkToGlobalResource" global="simpleValue" type="java.lang.Integer"/> </Context> <Context path="/webapps/Timerecording" docBase="Timerecording" debug="0" reloadable="true" crossContext="true"> <!-- PostgreSQL anbindung --> <Resource name="jdbc/mze" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/mze"> <parameter> <name>factory</name> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> </parameter> <parameter> <name>url</name> <value>jdbc:postgresql://127.0.0.1:5432/mze</value> </parameter> <parameter> <name>driverClassName</name> <value>org.postgresql.Driver</value> </parameter> <parameter> <name>username</name> <value>mze</value> </parameter> <parameter> <name>password</name> <value>mze</value> </parameter> <parameter> <name>maxActive</name> <value>20</value> </parameter> <parameter> <name>maxIdle</name> <value>10</value> </parameter> <parameter> <name>maxWait</name> <value>3000</value> </parameter> </ResourceParams> </Context> </Host> </Engine> </Service> </Server> ----------------------------------------------- Thank you for all help Matthias _______________________________________________________________________ Ein Grund zum Feiern: Die PC Praxis ermittelt zwischen 10 grossen Mailprovidern WEB.DE FreeMail als Testsieger http://f.web.de/?mc=021190
Matthias, Have you read this ? http://doc.postgresintl.com/jdbc/ch11s04.html If it still doesn't work let me know. Dave On Wed, 2004-03-03 at 10:26, Matthias Vach wrote: > Hi all, > first of all, sorry for this long mail, but i´m working on this problem since 4 days. And i really > need help. > I read a lot of websites about this problem but i still can't fix my problem so i hope you could > help me. > > Thank you very much. > > Every time i try to connect the postgresql-Database with my little JSP (running in Tomcat) i got > this Error: > --> java.sql.SQLException: Cannot load JDBC driver class 'null' <-- > > my environment > ----------------------------------------------- > PostgreDB and Tomcat are running on the same Server. > - the DB is named "mze" > - the user for this DB is named also "mze" > - the user has no password for the DB so it's "" > > my Tomcat version 4.1.18 > my Tomcat is listening on Port 4444 > > my Tomcat-Directory is: /opt/jakarta/tomcat > the Environment varibabl is: CATALINA_HOME=/opt/jakarta/tomcat > > the Name of my Webapplication is: > %CATALINA_HOME%/webapps/Timerecording > > my jsp is lying in: > %CATALINA_HOME%/webapps/Timerecording/WEB-INF/jsp > > my javaclass is lying in: > %CATALINA_HOME%/webapps/Timerecording/WEB-INF/src > > the JDBC-Driver "pg73jdbc3.jar is lying in: > %CATALINA_HOME%/common/lib > ----------------------------------------------- > > > web.xml of my webapp: > ----------------------------------------------- > <?xml version="1.0" encoding="UTF-8"?> > <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" > "http://java.sun.com/dtd/web-app_2_3.dtd"> > > <web-app> > <servlet>....</servlet> > <servlet-mapping>....</servlet-mapping> > > <resource-ref> > <description>postgreSQL Connection</description> > <res-ref-name>jdbc/mze</res-ref-name> > <res-type>javax.sql.DataSource</res-type> > <res-auth>Container</res-auth> > </resource-ref> > </web-app> > ----------------------------------------------- > > > javaclass of my webapp > ----------------------------------------------- > public class Order { > String connectionState = "Not Connected"; > > public void init() throws Exception { > DataSource ds=null; > Connection conn=null; > > Context ctx = new InitialContext(); > ds = (DataSource) ctx.lookup("java:comp/env/jdbc/mze"); > > try{ > conn = ds.getConnection(); //<----------------EXCEPTION HERE > } > catch(Exception e){ throw new Exception("Boom - No Connection -->"+e); } > > try { > if (conn != null) { > ... > conn.close(); > } > > } > catch (Exception e) {throw new Exception(" conn == null -->" + e); } > } > ----------------------------------------------- > > > server.xml of my tomcat > (sorry i don´t know what is important to fix my problem.So it´s very long! Sorry! > the most important is at the tail of this file): > ----------------------------------------------- > <Server port="8005" shutdown="SHUTDOWN" debug="0"> > > <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" debug="0"/> > <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" > debug="0"/> > > <GlobalNamingResources> > <Environment name="simpleValue" type="java.lang.Integer" value="30"/> > <Resource name="UserDatabase" auth="Container" > type="org.apache.catalina.UserDatabase" > description="User database that can be updated and saved"></Resource> > <ResourceParams name="UserDatabase"> > <parameter> > <name>factory</name> > <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value> > </parameter> > <parameter> > <name>pathname</name> > <value>conf/tomcat-users.xml</value> > </parameter> > </ResourceParams> > </GlobalNamingResources> > > <Service name="Tomcat-Standalone"> > > <!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 --> > <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" > port="4444" minProcessors="5" maxProcessors="75" > enableLookups="true" redirectPort="8443" > acceptCount="100" debug="0" connectionTimeout="20000" > useURIValidationHack="false" disableUploadTimeout="true" /> > > <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 --> > <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" > port="8009" minProcessors="5" maxProcessors="75" > enableLookups="true" redirectPort="8443" > acceptCount="10" debug="0" connectionTimeout="0" > useURIValidationHack="false" > protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/> > > <!-- Define the top level container in our container hierarchy --> > <Engine name="Standalone" defaultHost="localhost" debug="0"> > > <!-- Global logger unless overridden at lower levels --> > <Logger className="org.apache.catalina.logger.FileLogger" > prefix="catalina_log." suffix=".txt" > timestamp="true"/> > > <!-- Because this Realm is here, an instance will be shared globally --> > <Realm className="org.apache.catalina.realm.UserDatabaseRealm" > debug="0" resourceName="UserDatabase"/> > > <!-- Define the default virtual host --> > <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" > autoDeploy="true"> > > <Logger className="org.apache.catalina.logger.FileLogger" > directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true"/> > > <!-- Tomcat Examples Context --> > <Context path="/examples" docBase="examples" debug="0" reloadable="true" > crossContext="true"> > <Logger className="org.apache.catalina.logger.FileLogger" > prefix="localhost_examples_log." suffix=".txt" timestamp="true"/> > <Ejb name="ejb/EmplRecord" type="Entity" > home="com.wombat.empl.EmployeeRecordHome" > remote="com.wombat.empl.EmployeeRecord"/> > > <Environment name="maxExemptions" type="java.lang.Integer" value="15"/> > <Parameter name="context.param.name" value="context.param.value" > override="false"/> > > <Resource name="jdbc/EmployeeAppDb" auth="SERVLET" > type="javax.sql.DataSource"/> > <ResourceParams name="jdbc/EmployeeAppDb"> > <parameter><name>username</name><value>sa</value></parameter> > <parameter><name>password</name><value></value></parameter> > > <parameter><name>driverClassName</name><value>org.hsql.jdbcDriver</value></parameter> > > <parameter><name>url</name><value>jdbc:HypersonicSQL:database</value></parameter> > </ResourceParams> > > <Resource name="mail/Session" auth="Container" type="javax.mail.Session"/> > <ResourceParams name="mail/Session"> > > <parameter><name>mail.smtp.host</name><value>localhost</value></parameter> > </ResourceParams> > > <ResourceLink name="linkToGlobalResource" > global="simpleValue" > type="java.lang.Integer"/> > > </Context> > > <Context path="/webapps/Timerecording" docBase="Timerecording" debug="0" > reloadable="true" crossContext="true"> > > <!-- PostgreSQL anbindung --> > <Resource name="jdbc/mze" auth="Container" type="javax.sql.DataSource"/> > <ResourceParams name="jdbc/mze"> > <parameter> > <name>factory</name> > <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> > </parameter> > <parameter> > <name>url</name> > <value>jdbc:postgresql://127.0.0.1:5432/mze</value> > </parameter> > <parameter> > <name>driverClassName</name> > <value>org.postgresql.Driver</value> > </parameter> > <parameter> > <name>username</name> > <value>mze</value> > </parameter> > <parameter> > <name>password</name> > <value>mze</value> > </parameter> > <parameter> > <name>maxActive</name> > <value>20</value> > </parameter> > <parameter> > <name>maxIdle</name> > <value>10</value> > </parameter> > <parameter> > <name>maxWait</name> > <value>3000</value> > </parameter> > </ResourceParams> > </Context> > > </Host> > </Engine> > </Service> > </Server> > ----------------------------------------------- > > Thank you for all help > Matthias > > > > > > > > > > _______________________________________________________________________ > Ein Grund zum Feiern: Die PC Praxis ermittelt zwischen 10 grossen > Mailprovidern WEB.DE FreeMail als Testsieger http://f.web.de/?mc=021190 > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html > -- Dave Cramer 519 939 0336 ICQ # 14675561
Hi, Dave, i´ve read this document and i did it like the document says. except two little things: - i made a new <context-tag> because the exsisting context-tag bases on the Tomcat/examples-directory and my applicationis not lying there. My tag: <Context path="/webapps/Timerecording" docBase="Timerecording" debug="0" reloadable="true" crossContext="true"> - i do not have the parameter: <parameter><name>validationQuery</name><value>select version();</value></parameter> but this can´t be the problem bacause + i read a lot and this is the first time i read about these parameter so i think its optional. + if this would be the problem, then the Exception would be an other. Thank you Matthias pg@fastcrypt.com schrieb am 03.03.04 17:29:47: > > Matthias, > > Have you read this ? > http://doc.postgresintl.com/jdbc/ch11s04.html > > If it still doesn't work let me know. > > Dave ______________________________________________________________________ Extra-Konto: 2,50 %* Zinsen p. a. ab dem ersten Euro! Nur hier mit 25 Euro-Tankgutschein & ExtraPrämie! https://extrakonto.web.de/?mc=021110
On 03/03/2004 15:26 Matthias Vach wrote: > [snip] > <Context path="/webapps/Timerecording" docBase="Timerecording" debug="0" > reloadable="true" crossContext="true"> You don't need /webapps as part of your path. -- Paul Thomas +------------------------------+---------------------------------------------+ | Thomas Micro Systems Limited | Software Solutions for the Smaller Business | | Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk | +------------------------------+---------------------------------------------+
Matthias, Can you send me your xml file ? Dave On Thu, 2004-03-04 at 05:23, Matthias Vach wrote: > Hi, Dave, > > i´ve read this document and i did it like the document says. > > except two little things: > - i made a new <context-tag> because the exsisting context-tag bases on the Tomcat/examples-directory and my applicationis not lying there. > My tag: > <Context path="/webapps/Timerecording" docBase="Timerecording" debug="0" reloadable="true" crossContext="true"> > > - i do not have the parameter: > <parameter><name>validationQuery</name><value>select version();</value></parameter> > > but this can´t be the problem bacause > + i read a lot and this is the first time i read about these parameter so i think its optional. > + if this would be the problem, then the Exception would be an other. > > Thank you > Matthias > > > pg@fastcrypt.com schrieb am 03.03.04 17:29:47: > > > > Matthias, > > > > Have you read this ? > > http://doc.postgresintl.com/jdbc/ch11s04.html > > > > If it still doesn't work let me know. > > > > Dave > ______________________________________________________________________ > Extra-Konto: 2,50 %* Zinsen p. a. ab dem ersten Euro! Nur hier mit 25 > Euro-Tankgutschein & ExtraPrämie! https://extrakonto.web.de/?mc=021110 > -- Dave Cramer 519 939 0336 ICQ # 14675561