File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SocketTimeoutException when doing JNDI lookup

 
Vish Shukla
Ranch Hand
Posts: 111
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Vish Shukla
Ranch Hand
Posts: 111
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic