1 2 Previous Next 18 Replies Latest reply on Dec 5, 2008 4:34 AM by hiningenteki

    Why localhost?

      Hi,

      my client application tries to connect to localhost all the time despite the fact that I specified another server in the configuration files. There was an opinion that localhost is used by default if some key has not been specified.

      So, the question is: how can this issue be handled?

      Thanks in advance. :)

        • 1. Re: Why localhost?
          tfennelly

          I assume this is related to JBoss ESB, right? More info please. Can't help based on what's provided.

          • 2. Re: Why localhost?

            OK, I have a client application that connects to a remote JBoss ESB server. As usual, I used to run the app on the local machine with a local version of JBoss launched. Now that the remote connections were needed, I just replaced "localhost" in configs for the remote server's IP. However, when I launch my app (the local JBoss not running) an exception is thrown, like

            16:17:52,250 DEBUG [NamingContext] Failed to connect to localhost:1099
            javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]
             at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:274)
             at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)


            And it does seem very strange because localhost is nowhere to be found in the whole project.

            • 3. Re: Why localhost?
              tfennelly

              What are you using t make the invocation? Is there more of an exception there? Anything in the server logs? Don't be shy about giving more detail ;)

              • 4. Re: Why localhost?

                 

                16:40:28,656 DEBUG [NamingContext] Failed to connect to localhost:1099
                javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]
                 at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:274)
                 at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)
                 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
                 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
                 at javax.naming.InitialContext.lookup(Unknown Source)
                 at org.jboss.soa.esb.helpers.NamingContextPool.createContext(NamingContextPool.java:350)
                 at org.jboss.soa.esb.helpers.NamingContextPool.getContext(NamingContextPool.java:304)
                 at org.jboss.soa.esb.helpers.NamingContextPool.getContext(NamingContextPool.java:159)
                 at org.jboss.soa.esb.helpers.NamingContextPool.getNamingContext(NamingContextPool.java:410)
                 at org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPool.initConnection(JmsConnectionPool.java:500)
                 at org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPool.getSession(JmsConnectionPool.java:214)
                 at org.jboss.internal.soa.esb.couriers.JmsCourier.getJmsSession(JmsCourier.java:158)
                 at org.jboss.internal.soa.esb.couriers.JmsCourier.createMessageProducer(JmsCourier.java:319)
                 at org.jboss.internal.soa.esb.couriers.JmsCourier.deliver(JmsCourier.java:188)
                 at org.jboss.internal.soa.esb.couriers.TwoWayCourierImpl.deliver(TwoWayCourierImpl.java:189)
                 at org.jboss.soa.esb.client.ServiceInvoker$EPRInvoker.attemptDelivery(ServiceInvoker.java:563)
                 at org.jboss.soa.esb.client.ServiceInvoker$EPRInvoker.access$200(ServiceInvoker.java:485)
                 at org.jboss.soa.esb.client.ServiceInvoker.post(ServiceInvoker.java:345)
                 at org.jboss.soa.esb.client.ServiceInvoker.deliverSync(ServiceInvoker.java:203)
                 at com.auguris.haruspex.test.MessageUtil$MessageThread.run(MessageUtil.java:330)
                 at java.lang.Thread.run(Unknown Source)
                Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]
                 at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:248)
                 ... 20 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 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:84)
                 at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
                 at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:244)
                 ... 20 more


                This is the whole exception in the console. The server logs... It's all about the client who cannot connect to a remote server trying the notorious localhost instead.

                I could send configuration files: jbossesb-properties.xml, jboss-esb.xml to make the full picture. But there's not even a slightest mention of localhost.

                To add, my code that invokes the connection from MessageUtil.java:

                ServiceInvoker invoker = new ServiceInvoker( category, service );
                 Message replyMessage = null;
                 try {
                 replyMessage = invoker.deliverSync( requestMessage, timeout );
                 }
                 catch ( FaultMessageException e ) {
                 logger.error( e.getMessage(), e );
                 }


                • 5. Re: Why localhost?
                  kurtstam

                  When you start your JMS server (likely to be jbossesb) to what IP address are you binding it? (I'm referring to the -b option on startup). By default it binds to localhost. So a lookup in JNDI will return the queue to be bound to 'localhost' no matter what it is you specify in the jboss-esb.xml. So try starting with -b <ipaddress of the server>

                  Hope this helps

                  --Kurt

                  • 6. Re: Why localhost?
                    kconner

                    That is not correct, the values in jboss-esb.xml will override the setting used in -b and not the other way around. These values are then added to the EPR stored within the registry.

                    If you have updated to a later version of ESB, as suggested in the other thread, then the fault may be in the registry as there may still be stale EPRs from the previous run.

                    If you are still using hsql as the datasource then the easiest way to determine if this is the case is to do the following
                    - stop the server
                    - remove the server/XXX/data directory
                    - restart the server

                    There are other solutions, but this is likely to be the fastest.

                    • 7. Re: Why localhost?

                      The problem is not about the server. It's about the client and there is no /data directory.

                      Look, I have a client application. The server is working perfectly on another computer. I launch the client and - to my surprise - it throws exception that it cannot connect to... localhost?! Stop, where the hell does it come from? I replaced all localhost strings in the configs used by the client. Why does the app try to connect to it?

                      It's very strange. And I don't even have a clue.

                      • 8. Re: Why localhost?
                        rmolin

                        Beware of configurations like this:

                        <jms-provider name="JBossMQ"
                        connection-factory="ConnectionFactory"
                        jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
                        jndi-URL="localhost">
                        <jms-bus busid="quickstartGwChannel">
                        <jms-message-filter
                        dest-type="QUEUE"
                        dest-name="queue/quickstart_webservice_consumer_wise_Request_gw"


                        The 'localhost' will be picked up by the ServiceInvoker in the client.

                        • 9. Re: Why localhost?
                          kconner

                          As I said earlier, it comes from the registry which is stored on the server.

                          The service invoker queries the registry to find out where the services are located, using the retrieved EPRs to determine how the connection is to be made.

                          If you turn on DEBUG logging for the service invoker then you will see the set of EPRs being retrieved and it is likely to be in one of those.

                          BTW have you updated your server yet? If you are still on ESB 4.2.1 then you will have other problems.

                          • 10. Re: Why localhost?

                            Well, I seem to understand. I use jar-files from 4.4GA, while we are using 4.3. We'll try to solve this with a JBoss 4.4 server.

                            Actually, after the /data directory was deleted on the server, I could establish a connection but it could handle only two queries and refused any further ones.

                            I'm not sure that the problem lies with different versions but I'll give it a try. I'll let you know. Thank you all. :)

                            • 11. Re: Why localhost?
                              kconner

                              Here is an example of one issue that would affect you, fixed in ESB 4.3.

                              https://jira.jboss.org/jira/browse/JBESB-1555

                              • 12. Re: Why localhost?
                                kconner

                                Ignore my last, it appears you are using 4.3+ rather than 4.2.1 :)

                                • 13. Re: Why localhost?

                                  No problem, but there's a strange thing. Despite the fact that the server is named 4.3, it shows 4.2.2 GA in the log. :)

                                  P. S. It shows 4.2.2 GA even in the 4.4 version. :)

                                  • 14. Re: Why localhost?
                                    kconner

                                    I believe you may be seeing the version of the server it is based on rather than the ESB version.

                                    What do you get if you run

                                    java -jar jbossesb-rosetta.jar


                                    1 2 Previous Next