tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frederic Monclar <frederic.monc...@profium.com>
Subject Does Tomcat4.0 create automatically an InitialContext ?
Date Thu, 21 Feb 2002 11:29:27 GMT
Hello,

I try to access to my Oracle database thanks to the new services of
Tomcat4.0.
I read all the interesting documentation on the Jakarta-Tomcat web site
:

http://jakarta.apache.org/tomcat/tomcat-4.0-doc/jndi-resources-howto.html
"Tomcat 4 provides a JNDI InitialContext implementation instance to web
applications running under it,
 in a manner that is compatible with those provided by a Java2
Enterprise Edition application server.
Entries in this InitialContext are configured in the
$CATALINA_HOME/conf/server.xml file, and may be referenced by the
following elements in the web application deployment descriptor
(/WEB-INF/web.xml) of your web application:"

and I tried the following :

server.xml (located in /usr/local/jakarta-tomcat-4.0.2/conf):
-------------------------------------------------------------
<Context path="/Test" docBase="/home/fmo/myWebProject/" debug="4"
         reloadable="true" crossContext="true">

  <Logger className="org.apache.catalina.logger.FileLogger"
          prefix="localhost_test." suffix=".txt"
          timestamp="true"/>

  <Resource name="jdbc/SIR_DB" auth="Container"
type="javax.sql.DataSource"/>

  <ResourceParams name="jdbc/SIR_DB">
    <parameter>
      <name>user</name>
      <value>fred</value>
    </parameter>
    <parameter>
      <name>password</name>
      <value>fred</value>
    </parameter>
    <parameter>
      <name>driverClassName</name>
      <value>oracle.jdbc.driver.OracleDriver</value>
    </parameter>
    <parameter>
      <name>driverName</name>
      <value>jdbc:oracle:thin:@ukki:1521:develdb</value>
    </parameter>
  </ResourceParams>

</Context>

my web.xml (located in /home/fred/myproject/WEB-INF/):
------------------------------------------------------
<resource-ref>
        <description>Resource reference to a factory for
java.sql.Connection</description>
        <res-ref-name>jdbc/SIR_DB</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
</resource-ref>

my jsp file (located in /home/fred/myproject/):
-----------------------------------------------
...
<%
      javax.naming.Context  initCtx       = null;
      javax.naming.Context  envCtx        = null;
      // Obtain our environment naming context
      initCtx = new javax.naming.InitialContext();
      envCtx = (javax.naming.Context) initCtx.lookup("java:comp/env");
      // Look up our data source
      ds = (oracle.jdbc.pool.OracleDataSource)
envCtx.lookup("jdbc/SIR_DB");
...
%>
Where "ds" is always null.



So, do we have to create an initialContext, or to had a subcontext or to
install an LDAP directory to manage these resources ?
Does anyone could help me ?
Thanks in advance,
Fred.

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message