You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Perez Pola, Jorge" <jo...@eds.com> on 2003/03/19 14:00:34 UTC

Datasource Problem - NameNotFoundException

Hello all,
    
    I got a problem trying to configure tomcat in order to use a Datasource.
 
    The server is running SunOs 5.8. with tomcat 4.1.18
 
    I have this context defined in the server.xml
 

<!--=========================== TEST CONTEXT
======================================== -->
<Context className="org.apache.catalina.core.StandardContext"
crossContext="false" reloadable="false"
mapperClass="org.apache.catalina.core.StandardContextMapper"
useNaming="false" debug="0" swallowOutput="false" privileged="false"
wrapperClass="org.apache.catalina.core.StandardWrapper" docBase="gmep"
cookies="true" path="/gmep" cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper">
 
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="oracle.jdbc.driver.OracleDriver" userNameCol="user_id"
connectionName="xx" userTable="USER_ID" userCredCol="user_passwd"
digest="MD5" validate="true"
connectionURL="jdbc:oracle:thin:@2xx.239.1xx.235:1521:gmep"
userRoleTable="USER_ID" roleNameCol="user_group"
connectionPassword="appassword"/>
 
<Resource name="jdbc/gmepDB" scope="Shareable" type="javax.sql.DataSource"/>
 <ResourceParams name="jdbc/gmepDB">
  <parameter>
   <name>validationQuery</name>
   <value>select * from user_id</value>
  </parameter>
  <parameter>
   <name>maxWait</name>
   <value>5000</value>
  </parameter>
  <parameter>
   <name>maxActive</name>
   <value>4</value>
  </parameter>
  <parameter>
   <name>password</name>
   <value>anypassword</value>
  </parameter>
  <parameter>
   <name>url</name>
   <value>jdbc:oracle:thin:@xx.259.146.xx:1521:eghl</value>
  </parameter>
  <parameter>
   <name>driverClassName</name>
   <value>oracle.jdbc.driver.OracleDriver</value>
  </parameter>
  <parameter>
   <name>maxIdle</name>
   <value>2</value>
  </parameter>
  <parameter>
   <name>username</name>
   <value>perepo</value>
  </parameter>
   </ResourceParams>
</Context>
<!--  END TEST CONTEXT ================================================= -->

 
Notice that the context also has a Security Realm for logging purposes, and
it works OK
 
Also added to the web.xml 
 
<resource-ref>
     <description>TESTDatasource</description>
     <res-ref-name>jdbc/gmepDB</res-ref-name>
     <res-type>javax.sql.DataSource</res-type>
     <res-auth>Container</res-auth>
</resource-ref>

The code on the class:
 
  Context initialContext = new InitialContext();
  Context envContext  = (Context)initialContext.lookup("java:comp/env");
  dataSource = (DataSource)envContext.lookup("jdbc/gmepDB");
 
The exception:
    
    Name java: is not bound in this Context
    javax.naming.NameNotFoundException: Name java: is not bound in this
Context
 
Clues :
 
        - Classes for oracle : classes12.jar in  CATALINA_HOME/server/lib
      - Security Realm Works 
        - jdk 1.2 (also tried with jdk 1.3.1)
      - I have also tried trying  "java:/comp/env" "comp/env" .... hundreds
con combinations in the lookup, but nothing works.
      
 
 
I have read lot of messages regarding this issue.
 
But anyone could help me or give me a clue, this problem is really driving
me crazy.
 
Thanks in advance,
Cheers.