[jboss-user] [EJB 3.0] - Getting EJB from remote Jboss instance fails

henk53 do-not-reply at jboss.com
Sat Jul 11 07:44:21 EDT 2009


Hi, 

I'm trying to get an EJB from a remote Jboss AS 5.0.1 instance. On that same machine (in a different JVM) I can get this bean without any problems using basic code such as this:



  | public static void main(String[] args) throws Exception {			
  | 	Context context = getRemoteInitialContext();		
  | 	Object obj = context.lookup("EJBTest/SessionBean/remote");
  | }
  | 
  | public static Context getRemoteInitialContext() throws NamingException {		
  | 	Properties p = new Properties();
  | 	p.put(Context.INITIAL_CONTEXT_FACTORY, 	"org.jnp.interfaces.NamingContextFactory");
  | 	p.put(Context.URL_PKG_PREFIXES, 	"org.jboss.naming:org.jnp.interfaces");
  | 	p.put(Context.PROVIDER_URL, 		"jnp://localhost:1099");	
  | 	return new InitialContext(p);		
  | }
  | 

This is all straight from the many examples and tutorials and works like a charm.

However, when I try to connect from the machine next to me, using the same code (but changing localhost into the IP number), it doesn't work. I started Jboss AS with -b 0.0.0.0:


  | /opt/jdk1.6.0_12//bin/java -Djboss.server.log.threshold=WARN -Dprogram.name=run.sh -server -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true -Djava.endorsed.dirs=/opt/jboss/lib/endorsed -classpath /opt/jboss/bin/run.jar:/opt/jdk1.6.0_12//lib/tools.jar org.jboss.Main -b 0.0.0.0
  | 

I also confirmed that port 1099 is reachable from the other machine via telnet and nmap. E.g.:


  | telnet 10.0.0.2 1099
  | Trying ::1...
  | Connected to 10.0.0.2.
  | Escape character is '^]'.
  | ??srjava.rmi.MarshalledObject|???c?>IhashlocBytest
  | 


  | nmap -sT -p 1099 10.0.0.2
  | 
  | Starting Nmap 4.63a ( http://nmap.org ) at 2009-07-11 10:34 CEST
  | Interesting ports on 10.0.0.2:
  | PORT     STATE SERVICE
  | 1099/tcp open  unknown
  | 

So the host is reachable and the port is open. However, when I now execute the following from host 10.0.0.1:


  | public static void main(String[] args) throws Exception {			
  | 	Context context = getRemoteInitialContext();		
  | 	Object obj = context.lookup("EJBTest/SessionBean/remote");
  | }
  | 
  | public static Context getRemoteInitialContext() throws NamingException {		
  | 	Properties p = new Properties();
  | 	p.put(Context.INITIAL_CONTEXT_FACTORY, 	"org.jnp.interfaces.NamingContextFactory");
  | 	p.put(Context.URL_PKG_PREFIXES, 	"org.jboss.naming:org.jnp.interfaces");
  | 	p.put(Context.PROVIDER_URL, 		"jnp://10.0.0.2:1099");	
  | 	return new InitialContext(p);		
  | }
  | 

I get the following exception:


  | log4j:WARN No appenders could be found for logger (org.jnp.interfaces.TimedSocketFactory).
  | log4j:WARN Please initialize the log4j system properly.
  | Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: 10.0.0.2:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server 10.0.0.2:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 10.0.0.2:1099 [Root exception is java.net.ConnectException: Operation timed out]]]
  | 	at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1727)
  | 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:680)
  | 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:673)
  | 	at javax.naming.InitialContext.lookup(InitialContext.java:392)
  | 	at client.TestRemoteClientAccess.main(TestRemoteClientAccess.java:23)
  | Caused by: javax.naming.CommunicationException: Failed to connect to server 10.0.0.2:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 10.0.0.2:1099 [Root exception is java.net.ConnectException: Operation timed out]]
  | 	at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:311)
  | 	at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1698)
  | 	... 4 more
  | Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server 10.0.0.2:1099 [Root exception is java.net.ConnectException: Operation timed out]
  | 	at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:281)
  | 	... 5 more
  | Caused by: java.net.ConnectException: Operation timed out
  | 	at java.net.PlainSocketImpl.socketConnect(Native Method)
  | 	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
  | 	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
  | 	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
  | 	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
  | 	at java.net.Socket.connect(Socket.java:519)
  | 	at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:97)
  | 	at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:82)
  | 	at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:277)
  | 	... 5 more
  | 

After googling around a little, I played with the jnp.localAddress property, but this didn't really helped. Setting it to some bogus address correctly gives a binding error, but when I enter my real local IP I pretty much get the same exception as above.

I wonder if anyone could help me with this or point me to documentation describing how to do this. 

Many thanks in advance.





View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4243064#4243064

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4243064



More information about the jboss-user mailing list