6 Replies Latest reply on Jan 3, 2005 8:51 AM by pavanchoukhada

    connecting to localhost

    pavanchoukhada

      Hello
      I am facing a problem with jbossmq. My jboss server is running on one maching and i developed a jms client program on another machine.
      when i run this program, it trys to connect to the localhost and throws connection refused to 127.0.0.1. i am using jnpserver.jar to setup InitialContext and do lookup. i tried with jnp-client.jar too.
      what should i do to connect jms client to jbossmq running on another machine

        • 1. Re: connecting to localhost
          rino_salvade

          Hi

          Following is the code we're using to connect via JMS to a remote machine

          //Create the initial context:
           Properties env = new Properties();
           env.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
           env.setProperty(InitialContext.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
           env.setProperty(InitialContext.PROVIDER_URL, "jnp://10.124.131.17:1099);
          
           env.setProperty(InitialContext.SECURITY_PRINCIPAL, "guest");
           env.setProperty(InitialContext.SECURITY_CREDENTIALS, "guest");
          
           _initialContext = new InitialContext(env);
          
           //Create the connection factory and the connection object, it will be reused:
           _connectionFactoryName = inProperties.stringValue(CONFIG_KEY_CONNECTION_FACTORY_NAME);
           TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory)_initialContext.lookup(_connectionFactoryName);
           _topicConnection = topicConnectionFactory.createTopicConnection("guest", "guest");


          Have a look at the provider url.
          Since we use as well ejbs etc. we have the jbossall-client .jar included.
          Hope it helps

          • 2. Re: connecting to localhost
            pavanchoukhada

            hello
            i have done the same thing but not working.
            this programin is trying to connect to 127.0.0.1 rather then remote machine.
            i think PROVIDER_URL might be some hard coded in NamingContextFactory class or my program might be reading properties from another file.
            it works on same machine but not working on remote machine.

            Thanks

            • 3. Re: connecting to localhost
              rino_salvade

              Then it could be that the file jndi.properties is somewhere on the classpath and it overrules your settings. It mght be in one of your jars or as well in JAVA_HOME/lib. Have a look at http://java.sun.com/products/jndi/tutorial/beyond/env/source.html

              • 4. Re: connecting to localhost
                pavanchoukhada


                yeh it might be getting from other property file on classpath.
                but since i did hard coded all env values in my program. I am putting all env values in Hashtable and passing it when i call InitialContext.
                Now when i call
                initContext.getEnvironment()
                that time i get tha values which i have set in hashtable.
                and accordin to the jndi tutorial if it gets env values from more then one source it merger all values with colon seperated them.

                but when i do lookup it trying to connect to the 127.0.0.1 rather then specified url and getting connection refused exception.
                well i guess it might be happening due to security issue. may be i do not have access rights to another pc, on which jboss server is running

                well what do you say....?

                thaks

                Pavan Kumar

                • 5. Re: connecting to localhost
                  rino_salvade

                  Well, then here is the next proposal. Which Invocation Layer are you using? We had a problem with the standard one to connect to a remote server as well. We then used UIL2 and the problem went away. See as well the topic http://www.jboss.org/index.html?module=bb&op=viewtopic&t=58106

                  • 6. Re: connecting to localhost
                    pavanchoukhada


                    i got it...now its working.
                    problem was with RMI server.
                    somehow my progam getting 127.0.0.1 when it need to contact to rmi server.

                    defaul rmi service run on localhost and my server pc's /etc/hosts file
                    has one entry
                    127.0.0.1 localhost
                    so there was a mapping to 127.0.0.1 and my client program getting this local loop back address for further communication with rmi.
                    so there are tow way for getting rid of this problem

                    either put one entry in /etc/hosts(server machine) file for server's ip address
                    i don't exactly what it should be

                    or
                    add one option in jboss/ run.sh
                    java -Djava.rmi.server.hostname=192.168.2.179
                    it will override default jboss rmi setting.


                    well rino_salvade thanks a lot for your support