tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Isen,Ciji" <ci...@tamu.edu>
Subject Re: Problem Configuring Datasource With Tomcat !
Date Fri, 06 Aug 2004 21:22:53 GMT
Hi,
You havent mentioned where the code is deployed.
It might be in ROOT or a webapp of your own; either way this is a case 
of not finding the jndi resource.
You ought to insert the resource entry in server.xml inside the Context 
which you plan to use the resource.
You can opt to define the resource inside the Context. The context might 
be defined in another file(depending on tomcat version)
at $CATALINA/conf/Catalina/localhost/YourWebApp.xml (ROOT.xml for default).

Another option would be to define a resource-ref tag inside your context 
to make the resource visible inside your context.

hope this helps.shoot back if you have more trouble.

Gig 'em
Ciji Isen


sandeep tandon wrote:

>Hi,
>
> 
>
>We are using eclipse with tomcat to deploy our web application that uses
>oracle data source. Following steps were performed to get connection
>pool:
>
> 
>
>1)                   Changes in server.xml of tomcat , added these lines
>in application context
>
><Resource name="jdbc/JOBS_DataSource" auth="Container"
>type="javax.sql.DataSource"/> 
>
> 
>
><ResourceParams name="jdbc/JOBS_DataSource">
>
>  <parameter>
>
>    <name>factory</name>
>
>    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>
>  </parameter>
>
>  <parameter>
>
>    <name>driverClassName</name>
>
>    <value>oracle.jdbc.driver.OracleDriver</value>
>
>  </parameter>
>
>  <parameter>
>
>    <name>url</name>
>
>    <value>jdbc:oracle:thin:@150.235.31.48:1521:EHRS</value>
>
>  </parameter>
>
>  <parameter>
>
>    <name>username</name>
>
>    <value>jasadm</value>
>
>  </parameter>
>
>  <parameter>
>
>    <name>password</name>
>
>    <value>jasadm</value>
>
>  </parameter>
>
>  <parameter>
>
>    <name>maxActive</name>
>
>    <value>20</value>
>
>  </parameter>
>
>  <parameter>
>
>    <name>maxIdle</name>
>
>    <value>10</value>
>
>  </parameter>
>
>  <parameter>
>
>    <name>maxWait</name>
>
>    <value>-1</value>
>
>  </parameter>
>
></ResourceParams>
>
> 
>
> 
>
>2)                   Changes in web.xml of application, added these
>lines
>
>      <resource-ref>
>
>             <description>JOBS Datasource</description>
>
>             <res-ref-name>jdbc/JOBS_DataSource</res-ref-name>
>
>             <res-type>javax.sql.DataSource</res-type>
>
>             <res-auth>Container</res-auth>
>
>      </resource-ref>
>
> 
>
>3)                   Used two different approaches in code to access the
>datasource
>
>First -    
>
>java.util.Hashtable props = new java.util.Hashtable();
>
>props.put(javax.naming.InitialContext.INITIAL_CONTEXT_FACTORY,
>"org.apache.commons.dbcp.BasicDataSourceFactory");
>
>      javax.naming.InitialContext context = new
>javax.naming.InitialContext(props);
>
>Object dataSourceObject = context.lookup("jdbc/JOBS_DataSource");
>
>      myDataSource =
>(DataSource)javax.rmi.PortableRemoteObject.narrow(dataSourceObject,
>DataSource.class);
>
> 
>
>//third line throws naming exception - Cannot instantiate class:
>org.apache.commons.dbcp.BasicDataSourceFactory
>
> 
>
>Second-
>
>            javax.naming.InitialContext initContext = new
>InitialContext();
>
>            Context envContext  =
>(Context)initContext.lookup("java:/comp/env");
>
>      Object dataSourceObject =
>envContext.lookup("jdbc/JOBS_DataSource");
>
>//last line throws errors -> Source not found for
>NamingContext.lookup(String) line: 197
>
>//Source not found for BasicDataSource.getConnection(String, String)
>line: 532
>
>Have placed the required commons-dbcp.jar ,commons-pool.jar ,
>commons-collection.jar, classes12.jar in <tomcat-install-dir>\common\lib
>folder.
>
>Any help in this regard will be highly appreciated.
>
> 
>
>Thanks & Regards,
>
>Sandeep Tandon
>
>JOBS - CSPD
>
>C-09 / X-6165
>
> 
>
> 
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message