1 Reply Latest reply on Nov 11, 2004 7:57 PM by Scott Stark

    Localhost getting automatically contacted

    Kalyan Newbie

      Hi,

      Today I have seen a situation where the client, automatically picks up the local host to execute a bean call, even if you specify the PROVIDER_URL to be pointing to someother machine (and in case the remote server is down).

      This is how it happened:

      I had a test ejb deployed on a remote machine's JBoss server (which is running on a solaris machine). This server is shutdown and is not running. I have an instance of JBoss running on my local machine (on Windows). I deployed the same bean in the server on my machine.
      I forgot to update the provider url in my client to point to localhost and started running the client. To my surprise, the client was able to execute the bean call.

      Failed to connect to server:6500
      javax.naming.CommunicationException: Failed to connect to server server:6500 [Root exception is javax.naming.Ser
      viceUnavailableException: Failed to connect to server server:6500 [Root exception is java.net.ConnectException:
      Connection refused: connect]]
       at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:213)
       at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1185)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:516)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:509)
       at javax.naming.InitialContext.lookup(Unknown Source)
       at test.ejb.client.EJBClient.<init>(EJBClient.java:34)
       at test.ejb.client.EJBClient.main(EJBClient.java:58)
      Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server server:6500 [Root exception is
      java.net.ConnectException: Connection refused: connect]
       at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:187)
       ... 6 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.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 org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:69)
       at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:62)
       at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:183)
       ... 6 more
      
      Information: SUCCESS


      The info in bold shows that the call returned successfully.

      I remember looking at the code of NamingContext long time back, and it does try to send some packets across the network to see if there is any server running. If so, the getNamingServer() method returns that server. In this case, I think, this method is returning the local host.

      But, why is this functionality there in JBoss?

      Can someone throw some light on this?

      Thanks,
      Kalyan.