Hi, My suggestions: pretend DefaultContext doesn't exist. Put the Resource definition in an explicit Context tag for your webapp. Your web.xml is fine, and your code is fine.
Yoav Shapira Millennium Research Informatics >-----Original Message----- >From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >Sent: Wednesday, September 22, 2004 10:06 PM >To: tomat-user >Subject: Oracle Driver and JDBC-ODBC still refuses to load > > >I'm still having a driver loading problem. The error I get is " >:javax.servlet.ServletException: Cannot create JDBC driver of class '' for >connect URL 'null', cause: No suitable driver > at >org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageCon text >Impl.java:867)" >The tomcat version is 5.0.19. The OS is win2k. The Database is Oracle 9.2. >Java Version is 1.4.1 >I have tried copying the classes12.zip and renaming to classes12.jar. >Additionally I want to Oracle's web site and tried a couple of different >JDBC drivers. All gave the same error. I also tried the Oracle driver for >1.4 as my JAVA_HOME is 1.4.1.02. >I have tried using the JDBC ODBC link driver I received the same error. But >in this case I was not sure what jar file to copy to >$CATALINA_HOME\common\lib. So I am a bit unsure how valid that is. >I have tried making an xml file in $CATALINA_HOME\conf\Catalina\localhost >but that did not seem to do any good. >To test the ODBC-JDBC and Oracle JDBC I setup a DefaultContext in >server.xml. I would comment out one and just use the other. >Here are the files let me know if you note anything. >server.xml ><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"/> > <!-- Global JNDI resources --> > <GlobalNamingResources> > <!-- Test entry for demonstration purposes --> > <Environment name="simpleValue" type="java.lang.Integer" value="30"/> > <!-- Editable user database that can also be used by > UserDatabaseRealm to authenticate users --> > <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="Catalina"> > <Connector port="8080" > maxThreads="150" minSpareThreads="25" maxSpareThreads="75" > enableLookups="false" redirectPort="8443" acceptCount="100" > debug="0" connectionTimeout="20000" > disableUploadTimeout="true" /> > <Connector port="8009" > enableLookups="false" redirectPort="8443" debug="0" > protocol="AJP/1.3" /> > <Realm className="org.apache.catalina.realm.UserDatabaseRealm" >debug="0" resourceName="UserDatabase"/> ><!-- > <DefaultContext> > <Resource name="jdbc/OracleDB" auth="Container" >type="javax.sql.DataSource"/> > <ResourceParams name="jdbc/OracleDB"> > ><parameter><name>factory</name><value>org.apache.commons.dbcp.BasicData Sour >ceFactory</value></parameter> > <parameter><name>maxWait</name><value>-1</value></parameter> > <parameter><name>maxActive</name><value>20</value></parameter> > ><parameter><name>driverClassName</name><value>oracle.jdbc.driver.Oracle Driv >er</value></parameter> > ><parameter><name>url</name><value>jdbc:oracle:thin:@192.168.1.101:1521: to1< >/value></parameter> > <parameter><name>username</name><value>shankeyp</value></parameter> > <parameter><name>password</name><value>zaq123</value></parameter> > <parameter><name>maxIdle</name><value>10</value></parameter> > <parameter><name>removeAbandoned</name><value>true</value></parameter> > ><parameter><name>removeAbandonedTimeout</name><value>60</value></parame ter> > <parameter><name>logAbandoned</name><value>true</value></parameter> > </ResourceParams> > </DefaultContext> >--> > <DefaultContext> > <Resource name="jdbcodbc/OracleDB" auth="Container" >type="javax.sql.DataSource"/> > <ResourceParams name="jdbcodbc/OracleDB"> > ><parameter><name>factory</name><value>org.apache.commons.dbcp.BasicData Sour >ceFactory</value></parameter> > ><parameter><name>driverClassName</name><value>sun.jdbc.odbc.JdbcOdbcDri ver< >/value></parameter> > <parameter><name>url</name><value>jdbc:odbc:to1</value></parameter> > <parameter><name>username</name><value>shankeyp</value></parameter> > <parameter><name>password</name><value>zaq123</value></parameter> > </ResourceParams> > </DefaultContext> > <Host name="localhost" debug="0" appBase="webapps" > unpackWARs="true" autoDeploy="true" > xmlValidation="true" xmlNamespaceAware="false"> > <Logger className="org.apache.catalina.logger.FileLogger" > directory="logs" prefix="localhost_log." suffix=".txt" > timestamp="true"/> > > </Host> > </Engine> > </Service> ></Server> >web.xml ><?xml version="1.0" encoding="UTF-8"?> ><web-app xmlns="http://java.sun.com/xml/ns/j2ee" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee >http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" > version="2.4"> > <session-config> > <session-timeout> > 30 > </session-timeout> > </session-config> > <welcome-file-list> > <welcome-file> > index.jsp > </welcome-file> > <welcome-file> > index.html > </welcome-file> > <welcome-file> > index.htm > </welcome-file> > </welcome-file-list> > <resource-ref> > <description>Oracle Datasource example</description> > <res-ref-name>jdbc/OracleDB</res-ref-name> > <res-type>javax.sql.DataSource</res-type> > <res-auth>Container</res-auth> > </resource-ref> > <resource-ref> > <description>Oracle Datasource example JDBC ODBC</description> > <res-ref-name>jdbcodbc/OracleDB</res-ref-name> > <res-type>javax.sql.DataSource</res-type> > <res-auth>Container</res-auth> > </resource-ref> ></web-app> >The bean I simply call from a JSP page. >package mybean; >import java.beans.*; >import java.io.Serializable; >import javax.naming.Context; >import javax.naming.InitialContext; >import javax.sql.DataSource; >import java.sql.*; >public class testDBConn extends Object implements Serializable { > > public String testJDBCDBConn() throws Exception { > Context initContext = new InitialContext(); > Context envContext = >(Context)initContext.lookup("java:/comp/env"); > DataSource ds = (DataSource)envContext.lookup("jdbc/OracleDB"); > Connection conn = ds.getConnection(); > return "no error"; > } > > public String testODBCJDBCDBConn() throws Exception{ > Context initContext = new InitialContext(); > Context envContext = >(Context)initContext.lookup("java:/comp/env"); > DataSource ds = (DataSource)envContext.lookup("jdbcodbc/OracleDB"); > Connection conn = ds.getConnection(); > return "no error"; > } > >} >Any ideas would really be helpfully. >A couple of questions as I am new to Tomcat. >What the context tag does is give a way to divide up the server on >directory names? >For example htt://www.blah/test1/myjsp.jsp would be in the context of >/test1 right? >How can I see if Tomcat is looking in the jars provided by Oracle to see if >it is even finding the JDBC driver? >I am not really following the line "Context envContext = >(Context)initContext.lookup("java:/comp/env");" where is it getting >java:/comp/env from? I did change that just to see what would happen and >received a could not find context error. Why does java:/comp/env work? >I seem to be getting the picture that the JDBC drivers I am tring to use >are different than other JDBC driver in that they support connection >pooling. Is this correct? >I did have a suggestion to put it in a relam but I'm not sure how to do >that. I am willing to give it a try. Please give an example. >Thanks >Pete This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
