1 Reply Latest reply on May 14, 2005 9:27 AM by Kislay Lal

    Accessing JBOSS server by java clients of other networks

    Kislay Lal Newbie

      I am making a small chat application.
      Where I m using JMX (MBean), which binds a class to the JNDI and the class's functions inturn invokes EJBs when called by the Java clients residing on same or other networks.
      I m having JBOSS server running on a Static IP and Java Clients residing on other netwoks behind a router as nat machines inside LAN.
      When the JBOSS server is on the same LAN as the Java Clients everything is running fine. But when the Server is on the static IP and the client behind router then the java Clients are able to call the MBean functions via jnp and get the return values (if any), but the real problem is that the server is not able to push objects or messages to the Java Clients independently (which it is able to do in the LAN environment) . I send the Client's Remote object to the server to keep with itself mapped with username as soon as I get connected to the server.
      I have tried to put the code snippet to run the server

      "%JAVA%" %JAVA_OPTS% -Djava.rmi.server.hostname=1.2.3.4 -Djava.rmi.server.useLocalHostname=false -Djava.endorsed.dirs=%JBOSS_ENDORSED_DIRS% -classpath "%JBOSS_CLASSPATH%" org.jboss.Main %*
      


      at Java Client side
      Java Client extends
      UnicastRemoteObject

      and after getting the Initial Context LookUps the JNDI name of the MBean and then fires a login function passing its object as parameter to the function which Server keeps with it in a variable the function returns well with the values but when the server fires some values independently to the same client using its reference its not able to do that, it gives exception that it is not able to find the client, citing Client's Local IP which it can never find as that Local IP is not residing in its network but on some other network.
      I have tried alot to find some way thrugh it but still unsuccessful, kindly some help me.

      I m using the code below to find the Initial context of the server:
      prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      prop.put(Context.PROVIDER_URL, "jnp://1.2.3.4:1099");
      prop.put(Context.URL_PKG_PREFIXES, "org.jboss.namingrg.jnp.interfaces");


      The exception it gives when the server tries to fire a message to the client via an exposed Client function using Client reference it has stored with itself :

      18:21:23,796 INFO [STDOUT] java.rmi.ConnectException: Connection refused to hos
      t: 192.168.0.145; nested exception is:
       java.net.ConnectException: Connection timed out: connect
      18:21:23,828 INFO [STDOUT] at sun.rmi.transport.tcp.TCPEndpoint.newSocket(T
      CPEndpoint.java:567)
      18:21:23,828 INFO [STDOUT] at sun.rmi.transport.tcp.TCPChannel.createConnec
      tion(TCPChannel.java:185)
      18:21:23,828 INFO [STDOUT] at sun.rmi.transport.tcp.TCPChannel.newConnectio
      n(TCPChannel.java:171)
      18:21:23,828 INFO [STDOUT] at sun.rmi.server.UnicastRef.invoke(UnicastRef.j
      ava:101)
      18:21:23,828 INFO [STDOUT] at JBOSS.RMIClient_Stub.remoteReceive(Unknown So
      urce)
      18:21:23,828 INFO [STDOUT] at JBOSS.DialogImpl.check(DialogImpl.java:47)
      18:21:23,828 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(
      Native Method)
      18:21:23,828 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(N
      ativeMethodAccessorImpl.java:39)
      18:21:23,843 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
      ke(DelegatingMethodAccessorImpl.java:25)
      18:21:23,843 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3
      24)
      18:21:23,859 INFO [STDOUT] at sun.rmi.server.UnicastServerRef.dispatch(Unic
      astServerRef.java:261)
      18:21:23,859 INFO [STDOUT] at sun.rmi.transport.Transport$1.run(Transport.j
      ava:148)
      18:21:23,859 INFO [STDOUT] at java.security.AccessController.doPrivileged(N
      ative Method)
      18:21:23,875 INFO [STDOUT] at sun.rmi.transport.Transport.serviceCall(Trans
      port.java:144)
      18:21:23,875 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport.handleMess
      ages(TCPTransport.java:460)
      18:21:23,890 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport$Connection
      Handler.run(TCPTransport.java:701)
      18:21:23,890 INFO [STDOUT] at java.lang.Thread.run(Thread.java:534)
      18:21:23,890 INFO [STDOUT] Caused by: java.net.ConnectException: Connection tim
      ed out: connect
      18:21:23,906 INFO [STDOUT] at java.net.PlainSocketImpl.socketConnect(Native
       Method)
      18:21:23,906 INFO [STDOUT] at java.net.PlainSocketImpl.doConnect(PlainSocke
      tImpl.java:305)
      18:21:23,906 INFO [STDOUT] at java.net.PlainSocketImpl.connectToAddress(Pla
      inSocketImpl.java:171)
      18:21:23,921 INFO [STDOUT] at java.net.PlainSocketImpl.connect(PlainSocketI
      mpl.java:158)
      18:21:23,921 INFO [STDOUT] at java.net.Socket.connect(Socket.java:452)
      18:21:23,921 INFO [STDOUT] at java.net.Socket.connect(Socket.java:402)
      18:21:23,921 INFO [STDOUT] at java.net.Socket.<init>(Socket.java:309)
      18:21:23,937 INFO [STDOUT] at java.net.Socket.<init>(Socket.java:124)
      18:21:23,937 INFO [STDOUT] at sun.rmi.transport.proxy.RMIDirectSocketFactor
      y.createSocket(RMIDirectSocketFactory.java:22)
      18:21:23,937 INFO [STDOUT] at sun.rmi.transport.proxy.RMIMasterSocketFactor
      y.createSocket(RMIMasterSocketFactory.java:128)
      18:21:23,953 INFO [STDOUT] at sun.rmi.transport.tcp.TCPEndpoint.newSocket(T
      CPEndpoint.java:562)
      18:21:23,953 INFO [STDOUT] ... 16 more


      Sorry for the long mail...
      My mail id : kislaylal@yahoo.com
      Thanking You for any help.