13 Replies Latest reply on Mar 24, 2009 8:33 AM by andrechan

    remote access to ejb :java.rmi.UnknownHostException

    andrechan

      I'm using JBoss 4.2.2
      I have a server where an ejb project is deployed and a client in which there is the following code:


      Properties p = new Properties( );
      p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      p.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
      p.put(Context.PROVIDER_URL,"jnp://172.19.1.194:1099");

      Context context;
      try{
      context = new InitialContext(p);
      NavSenderRemote beanRemote = (NavSenderRemote) context.lookup("WSNavEAR/NavSenderBean/remote");

      Random r = new Random();
      int lat=r.nextInt(100);
      int lon= r.nextInt(100);

      beanRemote.setPosition(idUtente, lat, lon);

      }catch (NamingException e){
      e.printStackTrace();
      }

      Both client and server have the -b 0.0.0.0 option so they can have remote access.
      If I run this code on the server itself it works, instead if I run it on the client machine it gives the following error

      10:55:56,406 ERROR [STDERR] javax.naming.CommunicationException [Root exception
      is java.rmi.UnknownHostException: Unknown host: admin-836482f5f; nested exceptio
      n is:
      java.net.UnknownHostException: admin-836482f5f]
      10:55:56,406 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(Namin
      gContext.java:780)
      10:55:56,406 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(Namin
      gContext.java:627)
      10:55:56,406 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialCon
      text.java:351)
      10:55:56,406 ERROR [STDERR] at threads.RemoteTestRunner.doWork(RemoteTestRun
      ner.java:87)
      10:55:56,406 ERROR [STDERR] at threads.RemoteTestRunner.run(RemoteTestRunner
      .java:55)
      10:55:56,406 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
      10:55:56,406 ERROR [STDERR] Caused by: java.rmi.UnknownHostException: Unknown ho
      st: admin-836482f5f; nested exception is:
      java.net.UnknownHostException: admin-836482f5f
      10:55:56,406 ERROR [STDERR] at sun.rmi.transport.tcp.TCPEndpoint.newSocket(T
      CPEndpoint.java:572)
      10:55:56,406 ERROR [STDERR] at sun.rmi.transport.tcp.TCPChannel.createConnec
      tion(TCPChannel.java:185)
      10:55:56,406 ERROR [STDERR] at sun.rmi.transport.tcp.TCPChannel.newConnectio
      n(TCPChannel.java:171)
      10:55:56,406 ERROR [STDERR] at sun.rmi.server.UnicastRef.invoke(UnicastRef.j
      ava:94)
      10:55:56,406 ERROR [STDERR] at org.jnp.server.NamingServer_Stub.lookup(Unkno
      wn Source)
      10:55:56,406 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(Namin
      gContext.java:667)
      10:55:56,406 ERROR [STDERR] ... 5 more
      10:55:56,406 ERROR [STDERR] Caused by: java.net.UnknownHostException: admin-8364
      82f5f
      10:55:56,406 ERROR [STDERR] at java.net.PlainSocketImpl.connect(PlainSocketI
      mpl.java:177)
      10:55:56,406 ERROR [STDERR] at java.net.SocksSocketImpl.connect(SocksSocketI
      mpl.java:366)
      10:55:56,406 ERROR [STDERR] at java.net.Socket.connect(Socket.java:520)
      10:55:56,406 ERROR [STDERR] at java.net.Socket.connect(Socket.java:470)
      10:55:56,406 ERROR [STDERR] at java.net.Socket.<init>(Socket.java:367)
      10:55:56,406 ERROR [STDERR] at java.net.Socket.<init>(Socket.java:180)
      10:55:56,406 ERROR [STDERR] at sun.rmi.transport.proxy.RMIDirectSocketFactor
      y.createSocket(RMIDirectSocketFactory.java:22)
      10:55:56,406 ERROR [STDERR] at sun.rmi.transport.proxy.RMIMasterSocketFactor
      y.createSocket(RMIMasterSocketFactory.java:128)
      10:55:56,406 ERROR [STDERR] at sun.rmi.transport.tcp.TCPEndpoint.newSocket(T
      CPEndpoint.java:569)


      I'm starting to suspect my code works only on the same JVM. If this is the case then what kind of code should I use to work with another machine?
      Thanks in advance for your help