Remote JNDI/EJB Problems
cfrostrun Jun 18, 2004 9:50 AMHow's everyone doing today.. Good. :)
well my problem is driving me crazy, so I hope someone can help me
figure out why this is doing what it's doing.. i'm probably just doing
something "stupid"
I'm trying to call a remote stateless session bean from a different
physical box.
what i have working: i have a ear file w/ the war + ejb.jar all
enclosed and that is working beautifully. now i'm trying to
distribute out the processes. have a "client" either tomcat or a java
application sitting on one box, and the ejb container w/ my session
facades on the other box.
my environment: jboss 3.2.2-tomcat 4.1.24 bundle, linux redhat.
I've been monkeying around with the configuration and have gotten two
different errors.
the reason why i'm trying to list bindings is because of the second error that i'm getting. i was hoping that it would tell me what the objects are beings stored for a remote call.
1st error: java application (see source below) on box one trying to
connect to box 2 jndi but saying connection refused to 127.0.0.1. I
have also even removed (commented out) the localhost references to
/etc/hosts.
this is trying to do a simple listBindings.
java source:
import javax.naming.*;
import java.util.*;
import javax.rmi.PortableRemoteObject;
public class TestClient3 {
public static void main(String[] args){
try{
String sInitialContextFactory =
"org.jnp.interfaces.NamingContextFactory";
String sProviderUrl = "jnp://192.168.0.100:1099";
String sFactoryUrl = "java.naming.factory.url.pkgs";
// also tried sInterface org.jboss.naming:org.jnp.interface
String sInterface = "org.jboss.naming.client:org.jnp.interfaces";
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, sInitialContextFactory);
env.put(Context.PROVIDER_URL, sProviderUrl);
env.put(sFactoryUrl, sInterface);
InitialContext initialContext = new InitialContext(env);
System.out.println(initialContext.getEnvironment().toString());
NamingEnumeration enum = initialContext.listBindings("");
System.out.println(enum.toString());
while (enum.hasMoreElements()) {
System.out.println(enum.next().toString());
}
}catch(Exception e){ e.printStackTrace(System.err);
}
}
}
// my box ip i'm running this from is 192.168.0.194 and here's the
output results:
{java.naming.provider.url=192.168.0.100:1099,
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory,
java.naming.factory.url.pkgs=org.jboss.naming.client:org.jnp.interfaces}
javax.naming.CommunicationException [Root exception is
java.rmi.ConnectException: Connection refused to host: 127.0.0.1;
nested exception is:
java.net.ConnectException: Connection refused]
at org.jnp.interfaces.NamingContext.listBindings(NamingContext.java:796)
at org.jnp.interfaces.NamingContext.listBindings(NamingContext.java:735)
at javax.naming.InitialContext.listBindings(InitialContext.java:396)
at xxx.xxx.xxx.xxx.client.TestClient3.main(TestClient3.java:48)
Caused by: java.rmi.ConnectException: Connection refused to host:
127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:101)
at org.jnp.server.NamingServer_Stub.listBindings(Unknown Source)
at org.jnp.interfaces.NamingContext.listBindings(NamingContext.java:747)
... 3 more
Any Ideas?
Problem two. I got the jndi connecting properly but when i try to do a
lookup w/ the same string name i'm using through jndi on the bundled
process it's coming up w/
javax.naming.CommunicationException [Root exception is
java.rmi.NoSuchObjectException: no such object in table]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:647)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at xxx.xxx.xxx.client.TestClient2.main(TestClient2.java:48)
Caused by: java.rmi.NoSuchObjectException: no such object in table
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
... 3 more
source:
public static void main(String args[]){
try{
String sInitialContextFactory =
"org.jnp.interfaces.NamingContextFactory";
String sProviderUrl = "jnp://zodiac:1099";
// zodiac is 192.168.0.100
String sFactoryUrl = "java.naming.factory.url.pkgs";
String sInterface = "org.jboss.naming:org.jnp.interfaces";
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, sInitialContextFactory);
env.put(Context.PROVIDER_URL, sProviderUrl);
env.put(sFactoryUrl, sInterface);
InitialContext ctx = new InitialContext(env);
Object jndi = ctx.lookup("zodiac_facade/BusinessService");
Object portable = PortableRemoteObject.narrow(jndi,
getEJBClassRef(nServiceId));
}catch(Exception e){ e.printStackTrace(System.err);
}
}
and the jndi lookup string works inside the web container on the same
box... I even got it working through the client application on the
same box.... apparently the problem is just when it's on a remote box.
there is no firewall i've turned off /etc/init.d/iptables.sh stop
i'm baffled,
someone please give me some pointers.
Chris