(BIG) Problems with bean-lookup in NAT enviroment, EJB3RC5,
nickthegreat Mar 16, 2006 7:18 AMEnviroment: JAS 4.0.4RC1, EJB3RC5
The error I get is:
javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: <external-ip>; nested exception is: java.net.ConnectException: Connection timed out: connect] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:722) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587) at javax.naming.InitialContext.lookup(Unknown Source) at GetBeans.lookup(GetBeans.java:72) at TestLookup.main(TestLookup.java:17) Caused by: java.rmi.ConnectException: Connection refused to host: <external-ip>; nested exception is: java.net.ConnectException: Connection timed out: connect at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source) at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source) at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source) at sun.rmi.server.UnicastRef.invoke(Unknown Source) at org.jnp.server.NamingServer_Stub.lookup(Unknown Source) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625) ... 4 more Caused by: java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(Unknown Source) at java.net.PlainSocketImpl.connectToAddress(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.<init>(Unknown Source) at java.net.Socket.<init>(Unknown Source) at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source) at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source) ... 10 more
Lookup Code is vanialla/standard:
private static Properties JNDINameFactory(String host)
 {
 Properties properties = new Properties();
 properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
 properties.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
 properties.put("java.naming.provider.url", "jnp://"+host );
 properties.put("jnp.disableDiscovery", "true");
 return properties;
 }
 public BeanContainer lookup() throws NamingException {
 BeanContainer bc = new BeanContainer();
 getEJBPropertiesFromFile(); // getting JBOSS server IP+port from file
 Properties p = JNDINameFactory(asIP+":"+asPort);
 System.out.println("HOST: "+asIP+" IP: "+asPort);
 Context context=null;
 try {
 System.out.println("inital context lookup");
 context = new InitialContext(p);
 System.out.println("done");
 } catch ( Exception ex ) { ex.printStackTrace(); return bc; }
 try {
 System.out.println("bean lookup");
 bc.CoreBean = (CoreServiceInterface) context.lookup("CoreServiceBean/remote");
 bc.ExoticBean = (ExoticInterface) context.lookup("ExoticBean/remote");
 System.out.println("done");
 } catch ( Exception ex ) { ex.printStackTrace(); return bc;}
 return bc;
 }
Well, basicly a well known problem, JNDI/JBOSS in NAT enviroment
The standard workaround:
Adding
-Djava.rmi.server.hostname="exptrernal-ip" \
-Djava.rmi.server.uselocalHostname=false \
to the jboss run-script / jboss JVM paramters.
of course I've forwared all RMI/JNDI ports correctly.
(1098/1099/4444/4445)
starting without(!) java.rmi.server.hostname ->
lookup works in intranet .. but not remotely
lookup from remote clients -> error msg:
javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: <internal-ip>; nested exception is:
this is ok/expected ...
but when starting with java.rmi.server.hostname="external-ip"
I ALWAYS get
javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: <external-ip>; nested exception is: ...
no matter if lookup is done from inernal-net or remotely.
real strange thing: if I try netcat external-ip 1099 it gives back same data.
if I look at the traffic via ethereal where are a couple a tcp/ip packets send from server to client and vice-verce on port 1099.
but it still gives the connection refused error !!!???
I've tried it in various(!) NAT enviroments, always the same behaviour.
I know the java.rmi.server.hostname= workaround worked when I worked on a NON-EJB3 projekt with JBOSS 4.0.3
(In the same(!) network / enviroment I want to get this EJB3 stuff working)
Please heeeeeeeeeeeeelp :)
Desparetly trying to get this working since days :-((((((
Anyone got JBOSS 4.0.4RC1+EJB3 (lookup) working in a NAT enviroment ????
thx i.a, ntg
 
     
    