tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Bender" <>
Subject RE: Configuring JNDI for tomcat
Date Wed, 16 Jun 2004 11:20:01 GMT
Sounds like nothing's running on localhost port 1099.  I'm not a Tomcat expert so I don't know
if Tomcat is supposed to be exposing its Naming Service on that port.  If it is, it isn't


-----Original Message-----
From: Russ Leong []
Sent: Tuesday, June 15, 2004 11:24 PM
Subject: Configuring JNDI for tomcat

Hi, I am trying to configure tomcat 5.025 on W2K to be accessible by other machines via JNDI.
I have tried using the registry method but am getting Connection refused. And when I try to
filesystem approach I get NameNotFoundException.

I am new to both Tomcat and JNDI and hope to get some pointers. 

The way I'm testing now(local machine first) is I run tomcat with my server resource which
I want to make accessible, then I try to "connect" by running my client code via the java
command on my command prompt.

The following is how I am trying with the registry approach -

( in C:\j2sdk1.4.2_04\jre\lib)

(iccs.xml in C:\jakarta-tomcat-5.0.25\conf\Catalina\localhost)
<Resource name="bean/Jndi" auth="Container" type="test.JndiBean"/> 
 <ResourceParams name="bean/Jndi"> 

(JndiBean class in C:\jakarta-tomcat-5.0.25\webapps\iccs\WEB-INF\classes\test)
package test;
public class JndiBean {
    private String foo = "Default Foo";
    public String getFoo()          { return (; }
    public void setFoo(String foo)  { = foo; }
    private int bar = 0;
    public int getBar()             { return (; }
    public void setBar(int bar)     { = bar; }

(JndiClient class in C:\jakarta-tomcat-5.0.25\webapps\iccs\WEB-INF\classes\test)
package test;
import javax.naming.*;

public class JndiClient {
    public static void main(String[] args) {
        try {
            Context initCtx = new InitialContext();
            Context envCtx = (Context) initCtx.lookup("java:comp/env");
            JndiBean bean = (JndiBean) envCtx.lookup("bean/Jndi");
            System.out.println("foo = " + bean.getFoo() + ", bar = " + bean.getBar());
        catch( Exception e ) { e.printStackTrace(); }

And here is the error that I get
C:\>java -classpath C:\jakarta-tomcat-5.0.25\webapps\iccs\WEB-INF\classes test.JndiClient
javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection
refused to host: local
host; nested exception is: Connection refused: connect]
        at com.sun.jndi.rmi.registry.RegistryContext.lookup(
        at com.sun.jndi.rmi.registry.RegistryContext.lookup(
        at javax.naming.InitialContext.lookup(
        at test.JndiClient.main(
Caused by: java.rmi.ConnectException: Connection refused to host: localhost; nested exception
is: Connection refused: connect
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(
        at sun.rmi.transport.tcp.TCPChannel.createConnection(
        at sun.rmi.transport.tcp.TCPChannel.newConnection(
        at sun.rmi.server.UnicastRef.newCall(
        at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
        at com.sun.jndi.rmi.registry.RegistryContext.lookup(
        ... 3 more
Caused by: Connection refused: connect
        at Method)
        at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(
        at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(
        ... 8 more

Deeplyy appreciate any help from anyone. Thanks.
View raw message