tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin HaleBoyes <kcbo...@yahoo.com>
Subject tomcat, JNDI naming, and OracleDataSource
Date Mon, 14 May 2001 22:34:45 GMT
I don't know if my original message made it to the list yet.  I received the
following error when I tried to send a question to tomcat-user list:

   ----- The following addresses had permanent fatal errors -----
<janirautiainen.com@namezero.com>
    (reason: 550 User unknown)

I'm not sure why it redirected to namezero.com.  Hope this one makes it!

I'm trying to get a JNDI example of my own working - the one in the example
context works fine.  I originally wrote because I couldn't even get an
IntialContext instantiation to work.  I solved that by making sure the
naming.jar file was in my application-context classpath.  Actually, I hope the
first message didn't make it to the list!

Anyway, here's the problem.  In my code, I instantiate an InitialContext
and then do a lookup for a DataSource (connection factory).  The lookup
fails with the following exception:

javax.servlet.ServletException: NamingNotFound Exception while looking up
java:comp/env/jdbc/NamingDataSource:
Name java:comp is not bound in this Context
        at NamingServlet.init(NamingServlet.java:39)
        at
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:802)
        at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:583)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231)
        at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:225)
        at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
        at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2175)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
        at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
        at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:446)
        at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:162)
        at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
        at
org.apache.catalina.valves.RequestDumperValve.invoke(RequestDumperValve.java:219)
        at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
        at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:827)
        at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:904)
        at java.lang.Thread.run(Thread.java:484)


I'm at home right now so I don't have the code in fron of me but it is
basically as follows (with the naming exceptions caught and turned into
ServletExceptions):

import javax.naming.*;
import javax.sql.*;

public void init( ServletConfig config ) throws ServletException
{
  super.init(config);

  InitialContext ic = new InitialContext();
  DataSource ds =
        (DataSource)ic.lookup("java:comp/env/jdbc/NamingDataSource");
}


and here is my web.xml file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
  <display-name>Naming Test</display-name>
  <description>Test JNDI Naming</description>
  <servlet>
    <servlet-name>naming</servlet-name>
    <servlet-class>NamingServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>naming</servlet-name>
    <url-pattern>/naming</url-pattern>
  </servlet-mapping>
  <resource-ref>
    <res-ref-name>jdbc/NamingDataSource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>
</web-app>


So the exception says:
    Name java:comp is not bound in this Context
but isn't it enough to declare/define it in my web.xml file.
I'm going to look through the ejb specification tomorrow in case it sheds
any light (since the servlet spec says naming and resource references are
described in the ejb spec).

As an aside, what I'm actually trying to do is get an
OraclePooledConnectionDataSource (I think that's the class name?)
with the base class OracleDataSource in the oracle.jdbc.pool package but
I thought I'd start with a simpler case.  I'm also waiting to see if anyone
responds to "Andrew" <asd@ezan.ac.ru> as he has just asked a question very
similar to what I'm trying to do.

All help is appreciated,
Thanks,
Kevin


____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

Mime
View raw message