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.
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 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
Problem two appears to be unregistered applications or differring port
communications. (two different ports for a given service)
"Chris" <cbrou...@liquiddatainc.com> wrote in message
news:89b6b185.04061...@posting.google.com...
Thanks Bob for a reply back. I was wondering if you can give me a url
pointer that gives me an example of the java.policy implementation ?
to fix problem one.
> Problem two appears to be unregistered applications or differring port
> communications. (two different ports for a given service)
>
well i believe jndi is configured on port 1099 ( i will check tonight
to make sure). can you please elaborate a little more. the
application is registered and working as a bundled jboss/tomcat
container on that box... if i try to remotely connect to that box is
where it's puking.
Thank you,
Chris
I'm sure you figured this out long ago, but I have had the exact same
problem and kept seeing your messages on google groups. So for the benefit
of future searchers: In my case, the problem boiled down to the fact that
the JBoss server thought its primary IP address was 127.0.0.1 - so returned
this to the remote client in the initial communication.
If you telnet to your JBoss server on port 1099 (telnet x.x.x.x 1099) you
should see a binary response. At the end of the response there'll be an IP
address followed by control characters. The IP address is readable.
This is the address the server thinks its serving on. If this is 127.0.0.1
then it's using the loopback address, and no remote client will be able to
connect. I guess this is JBoss telling the client where to make further JNDI
requests. If the server thinks its address is 127.0.0.1, the client then
tries to interrogate the machine it's running on, which fails of course.
In my case, there was an entry in /etc/hosts which went
127.0.0.1 venus venus.<mydomain>.com localhost localhost.localdomain
(The server knows its name is venus so at startup grabs 127.0.0.1 as its
address)
Editing this to
127.0.0.1 localhost localhost.localdomain
followed by
192.168.0.102 venus venus.<mydomain>.com
and then bouncing JBoss fixed it.
You can explicity set the address in the JBoss startup scripts as well, as a
system property, if you don't want / can't edit your hosts file.
Hope this helps someone sometime,
Steve
Steve,
I am having very similar problems. I am try to access an ejb from an
ejb client that is on the other side of a firewall. I know I can get
through the firewall, but still get the Connection refused to host:
192.168.0.30.
My provider url is
10.0.0.10:1099
Which then gets redirected to the internal address 192.168.0.30:1099
by the firewall.
I believe the ejb client is then using ip address 192.168.0.30 which
is no good.
I think it has to keep using the 10.0.0.10 address?
You mentioned setting the address in the jboss startup scripts. What
exactly do you change and what is the system property.
Thanks,
Niels
Found the solution to this problem at
http://www.jboss.org/wiki/Wiki.jsp?page=UsingJBossBehindAFirewall
This solution was for Jboss 3.2.5. As I was using 3.0.3 I had to add the line
<attribute name="RmiPort">1098</attribute>
in the <mbean code="org.jboss.naming.NamingService" ...>
xml in the jboss-service.xml file.
All working now.
Cheers,
Niels