aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes SocketTimeoutException when doing JNDI lookup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "SocketTimeoutException when doing JNDI lookup " Watch "SocketTimeoutException when doing JNDI lookup " New topic
Author

SocketTimeoutException when doing JNDI lookup

Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
Hello,

I am trying to do JNDI lookup for remote stateless session bean. CommunicationException & SocketTimeoutException is thrown.

Isolation: When I have EJB server(JBoss) and client both in the same machine, and I try to connect using "java.naming.provider.url" = "localhost:1099", it works fine.. But if I change "localhost" by ip-address, it doesn't work. So when client is remote, then also its not working.

Here is the complete stack trace I am getting.


javax.naming.CommunicationException: Could not obtain connection to any of these urls: 192.168.0.42: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 192.168.0.42:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 192.168.0.42:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]]
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(Unknown Source)
at com.ejbtest.server.businessdelegates.ServiceLocator.getRemoteService(ServiceLocator.java:74)
at com.ejbtest.server.businessdelegates.ServiceLocator.getRemoteService(ServiceLocator.java:78)
at com.ejbtest.server.businessdelegates.UserDelegate.<init>(UserDelegate.java:28)
at com.ejbtest.server.businessdelegates.UserDelegate.createInstance(UserDelegate.java:37)
at com.ejbtest.server.UserServiceImpl.main(UserServiceImpl.java:16)
Caused by: javax.naming.CommunicationException: Failed to connect to server 192.168.0.42:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 192.168.0.42:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:311)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1698)
... 8 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server 192.168.0.42:1099 [Root exception is java.net.ConnectException: Connection refused: connect]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:281)
... 9 more
Caused by: java.net.ConnectException: Connection refused: 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 org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:97)Completed lookup of UserBean

at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:82)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:277)
... 9 more
java.lang.NullPointerException
at com.ejbtest.server.businessdelegates.UserDelegate.insert(UserDelegate.java:43)
at com.ejbtest.server.UserServiceImpl.main(UserServiceImpl.java:21)


Thanks in advance.


Thanks & Regards,
Vishal S Shukla (SCJP 93%, SCWCD 94%, SCBCD 100%)
Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
Hello,

I got solution to this problem. Just launched JBoss with -b 0.0.0.0 as argument. This link helped me.

http://www.theserverside.com/discussions/thread.tss?thread_id=49698
 
 
subject: SocketTimeoutException when doing JNDI lookup