You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Cam Smith <ca...@solidstate.com.au> on 2003/10/22 01:18:22 UTC

DefaultContext + ResourceLink

Hi tomcat-dev,

I just downloaded the latest builds in the hope that this bug might be fixed:

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11662
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16116

Unfortunately it still seems to be present.  I'm happy to go with 4.1 or 
5.0 beta, but could someone please take a look at this?  I would have 
thought that global JDBC datasources plus auto-deployment is a pretty 
mainstream configuration.

thanks,


Cam Smith
Solid State
----------------
p:  613 9525 5040
f:   613 9593 8594
m: 0416 150 422
e: cam@solidstate.com.au


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


Re: DefaultContext + ResourceLink

Posted by Peter Harrison <pe...@nothingbutnet.co.nz>.
On Wed, 22 Oct 2003 12:18, Cam Smith wrote:
> Hi tomcat-dev,
>
> I just downloaded the latest builds in the hope that this bug might be
> fixed:
>
> http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11662
> http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16116
>
> Unfortunately it still seems to be present.  I'm happy to go with 4.1 or
> 5.0 beta, but could someone please take a look at this?  I would have
> thought that global JDBC datasources plus auto-deployment is a pretty
> mainstream configuration.

The following was posted a couple of days ago, and the bug marked as RESOLVED 
and FIXED. However, there was also the comment included below which seems to 
indicate that the resolution was *not* to place JDBC drivers in the 
common/lib directory, but rather add the JDBC jar to the classpath manually.

This is rather confusing. This is a different behavior to Tomcat 4.0.4 (which 
I'm using now), and is undocuented. Ideally it should be fixed so that the 
common/lib directory is used, as is the case with older versions.


------- Additional Comments From jarkkos@hotmail.com  2003-10-20 11:10 -------
I have been dealing with the same problem for a few days and managed to find 
one solution for it.
I'm using Tomcat 4.1.27 and Sybase database running on Win2K(also tried in XP 
and same assembly worked fine).

In my server.xml I have Context under <host> as follows:

<Context path="/MyApp" 
         docBase="MyApp"
         debug="5" 
         reloadable="true" 
         crossContext="true">           
   <Resource name="jdbc/dbref"
             auth="Container"
             type="javax.sql.DataSource"/>      
  <ResourceParams name="jdbc/dbref">
    <parameter>
      <name>factory</name>
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
      <name>maxActive</name>
      <value>10</value>
    </parameter>
    <parameter>
      <name>maxIdle</name>
      <value>2</value>
    </parameter>
    <parameter>
      <name>maxWait</name>
      <value>10000</value>
    </parameter>
    <parameter>
     <name>username</name>
     <value>report</value>
    </parameter>
    <parameter>
     <name>password</name>
     <value>report</value>
    </parameter>
    <parameter>
       <name>driverClassName</name>
       <value>com.sybase.jdbc2.jdbc.SybConnectionPoolDataSource</value>
    </parameter>        
    <parameter>
      <name>url</name>
      <value>jdbc:sybase:Tds:xxx:5000/dbname</value>
    </parameter>            
    <parameter>
      <name>removeAbandoned</name>
      <value>true</value>
          </parameter>
          <parameter>
      <name>removeAbandonedTimeout</name>
      <value>60</value>
    </parameter>
  </ResourceParams>
</Context>      

In my web.xml I have:

<resource-ref>
   <description>Sybase Datasource</description>
   <res-ref-name>jdbc/dbref</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
</resource-ref>

,and in Java:
Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
dataSource = (javax.sql.DataSource)envContext.lookup(dataSourceName);
Connection con = dataSource.getConnection();

I installed Java 2 Runtime Environment 1.4.2_01 and modified system variables:
JAVA_HOME = "j2re 1.4.2_01 install dir"
CLASSPATH = "3rd party database driver jar directory"
CATALINA_HOME = "Tomcat install dir"

Although Jakarta Tomcat 4.1 "JNDI Datasource HOW-TO" docs adviced not to 
install 3rd party database drivers anywhere else than in 
$CATALINA_HOME/common/lib I tried adding jar into CLASSPATH and it worked 
fine.
Make sure you have jre installed and JAVA_HOME set into that dir and it should 
work fine.


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