Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

SocketTimeoutException when doing JNDI lookup

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic