tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin HaleBoyes <kcbo...@yahoo.com>
Subject tomcat and naming
Date Mon, 14 May 2001 19:22:16 GMT
I'm trying to get a JNDI example running but I have run into trouble.
I'm using tomcat 4.0b3 on a RedHat Linux 6.2 box with JDK 1.3.0_02

I've created a servlet that tries to get the InitialContext in the init()
method but I always
get an exception when I run it.  Here is the servlet:

import javax.naming.NamingException;
import javax.naming.NameNotFoundException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.directory.InitialDirContext;

import javax.sql.*;

import javax.servlet.*;
import javax.servlet.http.*;


public class NamingServlet extends HttpServlet
{
	public void init() throws ServletException
	{
		DataSource datasource = null;
		InitialContext ic = null;
		String DATASOURCE_NAME = "java:comp/env/jdbc/NamingDataSource";

		try
		{
			ic = new InitialContext();
		}
		catch (NamingException ne)
		{
			throw new ServletException("Naming Exception while instantiating an Initial
Context:\n" + ne.getMessage());
		}

		try
		{
			datasource = (DataSource)ic.lookup(DATASOURCE_NAME);
		}
		catch (NameNotFoundException ne)
		{
			throw new ServletException("NamingNotFound Exception while looking up " +
DATASOURCE_NAME + ":\n" + ne.getMessage());
		}
		catch (NamingException ne)
		{
			throw new ServletException("Naming Exception while looking up " +
DATASOURCE_NAME + ":\n" + ne.getMessage());
		}
	}
}

I copied the jndi.jar  from catalina into my source lib directory.  I'm using
Oracle 8.1.7
javax.sql package for the DataSource classes but I don't think this is
important since I'm
not even making it that far.  Here's the exception I get when I access the
mapped URL
of http://localhost:8080/naming/naming  :

javax.servlet.ServletException: Naming Exception while instantiating an Initial
Context:
Cannot instantiate class: org.apache.naming.java.javaURLContextFactory
        at NamingServlet.init(NamingServlet.java:27)
        at javax.servlet.GenericServlet.init(GenericServlet.java:258)
        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 have the tomcat examples running, including the JNDI example, but I can't see
what I'm
doing that is different.  The only vague clue that I have is the
class-not-found
exception for org.apache.naming.java.javaURLContextFactory but I don't know
where to
go from there.

Any help would be appreciated,
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