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= -Djava.rmi.server.useLocalHostname=false -Djava.endorsed.dirs=%JBOSS_ENDORSED_DIRS% -classpath "%JBOSS_CLASSPATH%" org.jboss.Main %*

      at Java Client side
      Java Client extends

      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://");
      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:; nested exception is:
       java.net.ConnectException: Connection timed out: connect
      18:21:23,828 INFO [STDOUT] at sun.rmi.transport.tcp.TCPEndpoint.newSocket(T
      18:21:23,828 INFO [STDOUT] at sun.rmi.transport.tcp.TCPChannel.createConnec
      18:21:23,828 INFO [STDOUT] at sun.rmi.transport.tcp.TCPChannel.newConnectio
      18:21:23,828 INFO [STDOUT] at sun.rmi.server.UnicastRef.invoke(UnicastRef.j
      18:21:23,828 INFO [STDOUT] at JBOSS.RMIClient_Stub.remoteReceive(Unknown So
      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
      18:21:23,843 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
      18:21:23,843 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3
      18:21:23,859 INFO [STDOUT] at sun.rmi.server.UnicastServerRef.dispatch(Unic
      18:21:23,859 INFO [STDOUT] at sun.rmi.transport.Transport$1.run(Transport.j
      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
      18:21:23,875 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport.handleMess
      18:21:23,890 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport$Connection
      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
      18:21:23,906 INFO [STDOUT] at java.net.PlainSocketImpl.doConnect(PlainSocke
      18:21:23,906 INFO [STDOUT] at java.net.PlainSocketImpl.connectToAddress(Pla
      18:21:23,921 INFO [STDOUT] at java.net.PlainSocketImpl.connect(PlainSocketI
      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
      18:21:23,937 INFO [STDOUT] at sun.rmi.transport.proxy.RMIMasterSocketFactor
      18:21:23,953 INFO [STDOUT] at sun.rmi.transport.tcp.TCPEndpoint.newSocket(T
      18:21:23,953 INFO [STDOUT] ... 16 more

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