Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Remote JNDI/EJB Problem  RSS feed

 
C Broussard
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How'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 an 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, (client)linux redhat 9, server linux redhat 7.

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 being bound as.

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 rg.jnp.interface
String sInterface = "org.jboss.naming.client rg.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 rg.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 rg.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
 
Dale Seng
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried just putting the URL (only) in the properties? Maybe the defaults for the rest will work.

--Dale--
 
Jesus del Olmo
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:

When you start JBoss,

run.sh -Djboss.bind.address=IP -Djava.rmi.server.hostname=IP

The reason seems to be than JBoss has the wrong idea it shoul bind to. We had this problem and this seems to be the solution.

Please answer me if it works
 
C Broussard
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will it this over the weekend and see if it will help.

i don't want the whole container to go out to this location for lookups. i just wanted the calls from this chunk of code to go there.

thanks everyone again.


Originally posted by Jesus del Olmo:
Try this:

When you start JBoss,

run.sh -Djboss.bind.address=IP -Djava.rmi.server.hostname=IP

The reason seems to be than JBoss has the wrong idea it shoul bind to. We had this problem and this seems to be the solution.

Please answer me if it works
 
Amit Jaipaul
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chris,

Try giving ur appserver IP in /etc/hosts file of ur webserver linux box. As ur webserver is tyring lookup in the localhost itself even though u have commented out that mapping, it might be possible that by default ur webserver is looking up in the localhost only as it does not have any mapping to look up to.
 
Dave Gauthier
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Jesus had it right. The server is sending back an address for the client to use to try to create an RMI connection to transport the messages. It was sending back 127.0.0.1, though, which meant your client was trying to connect to itself. I got the "not found in table" problem when I was also running a server on the same machine as the client. If you pass in the 2 settings mentioned, the server will accept outside connections and send the IP address back to create the RMI connection.
 
parthiban subramaniam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys,
Was getting nowhere with my application having the same problem where every machine in our network had 2 IP's assigned to it and finally this post saved my day.

Cheers,
Parthi.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!