4 Replies Latest reply on Jul 13, 2002 1:14 PM by steckman

    Remote client doesn't work

    tthiele

      Hi, though many articles concern this topic I can't find any that helps me really.
      When I run my client program on the localhost it works fine.
      On a remote machine this Exception is thrown:

      java.rmi.ConnectException: Connection refused to host: 127.0.0.2; nested exception is:
      java.net.ConnectException: Connection refused: connect
      at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
      at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
      at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:101)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:349)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:333)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at de.ems.formserver.api.ejbcommon.APIServiceLocator.getAPIService(APIServiceLocator.java:82)
      at de.ems.formserver.app.apiclient.Main.main(Main.java:87)
      Caused by: java.net.ConnectException: Connection refused: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:295)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:161)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:148)
      at java.net.Socket.connect(Socket.java:425)
      at java.net.Socket.connect(Socket.java:375)
      at java.net.Socket.(Socket.java:290)
      at java.net.Socket.(Socket.java:118)
      at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
      at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:122)
      at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:562)
      ... 9 more

      this is strange, because my jndi-settings are pointing to the server machine:

      run.bat file:
      set CP=../lib/formserver-apiclient.jar
      set CP=%CP%;../lib/jboss-client.jar
      set CP=%cp%;../lib/jboss-j2ee.jar
      set CP=%cp%;../lib/jbosssx-client.jar
      set CP=%cp%;../lib/log4j.jar
      set CP=%cp%;../lib/cryptix32.jar
      set CP=%cp%;../lib/jnp-client.jar
      set CP=%cp%;../res

      set JO=-Denv-properties.jndiname=inmemory/env/properties
      set JO=%JO% -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      set JO=%JO% -Djava.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      set JO=%JO% -Djava.naming.provider.url=jnp://192.168.1.112:1099

      java -classpath %CP% %JO% de.ems.formserver.app.apiclient.Main %1 %2 %3 %4 %5 %6 %7

      set CP=../lib/formserver-apiclient.jar
      set CP=%CP%;../lib/jboss-client.jar
      set CP=%cp%;../lib/jboss-j2ee.jar
      set CP=%cp%;../lib/jbosssx-client.jar
      set CP=%cp%;../lib/log4j.jar
      set CP=%cp%;../lib/cryptix32.jar
      set CP=%cp%;../lib/jnp-client.jar
      set CP=%cp%;../res

      set JO=-Denv-properties.jndiname=inmemory/env/properties
      set JO=%JO% -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      set JO=%JO% -Djava.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      set JO=%JO% -Djava.naming.provider.url=jnp://192.168.1.112:1099

      java -classpath %CP% %JO% de.ems.formserver.app.apiclient.Main %1 %2 %3 %4 %5 %6 %7

      So, why does the client try to access a localhost IP address though
      a remote IP address is given? The jndi.properties also contains the same
      IP-Address.

      Thanks
      Tilo

        • 1. Re: Remote client doesn't work
          joelvogt

          Assuming you are running linux (red hat I guess) then the problem will be in your /etc/hosts. This is a bug/feature in .. damn can't remember, sun's jdk I think with rmi. Anyway what you need to do is make sure you have something like

          127.0.0.1 localhost.localdomain localhost
          192.168.1.112 MYCOMPUTER
          192.168.1.112 MYCOMPUTER.mydomain.com

          • 2. Re: Remote client doesn't work
            tthiele

            Bingo! the file /etc/hosts on the server machine contained a wrong line:

            127.0.0.2 ems-wks-001.emessages.de ems-wks-001

            which is nonsense. After removing this line everything worked fine.
            By the way my server machine is SuSE linux 8 and the client machine
            is NT4.

            Tilo

            • 3. Re: Remote client doesn't work
              steckman

              I'm seeing the exact same problem. My server is RedHat 7.2. But in this case my /etc/hosts has only a single line for the localhost, and I'm running a DNS server for client lookups on my local network. I can nslookup my client name from both the client and server, and do a reverse lookup, with no problems, so I don't think there is a problem with my DNS server's setup. Just for fun I tried adding my client to the /etc/hosts file, although it should be unnecessary, but it had no affect - I got the same exceptions thrown. My client is a Win2k machine. Any idea what's going on? Do you have a link to this JDK bug/feature description?

              • 4. Re: Remote client doesn't work
                steckman

                Please ignore my previous post. I restarted JBoss and now it is working.