RMI Connection

Hi there,
I am wondering is there anyway to make a RMI connection in such a manor as to allow the remote methods to be called from anywhere in the application, without re initializing the original connection.
For example say I have a client with the class classmain.java -the main class with the main method and classgui.java and classloginscreen.java
Then a server with the interface class and the main implementation class.
Now in the client main I have
public RemoteServerInterface remote;
then in classmain I make a call to a method setup connection,
the method is as follows
try {
remote = (RemoteServerInterface)Naming.lookup("rmi://127.0.0.1/servername");
catch (RemoteException ee) {
System.out.println("RemoteException: " + ee.getMessage());
ee.printStackTrace();
ok now I make an instance of clientgui from clientmain, and from clientgui i make an instance of classloginscreen. here I want to call for example
remote.test();
But I get a null pointer exception because remote is not defined. If I make a new variable as like the one in clientmain inside classloginscreen hence [public RemoteServerInterface remote; ] and
if I make a method inside classloginscreen which dose the code above, all works fine but I want to have one global connection so once I run classmain after that inside any other class I can just go remote.methodname();. is this possible or do I need to make a connection every time I am inside a different class.
any suggestions would be great.
Thanks
Cuspblue

>
any suggestions would be great.1. This has nothing to do with JDBC.
2. Patterns -> Singleton.
3. Don't expose the connection itself. Wrap it in something.

Similar Messages

  • Help on JSP-RMI connection

    Hi..
    can anyone provide me any tutorial/link which will help me in learning JSP and RMI connection. Like I need to acces RMI server object from JSP.

    Hi ...
    I didn't get any reply from any one....
    Is it possible to make Java Server Pages and RMI work together -
    to invoke a method on a server object from a JSP? And if, does
    someone know of a good tutorial, article etc., on this matter?
    waiting for ur reply!!!!

  • RMI Connection Issue

    I am trying to implement an RMI connection and am consistently getting the message:
    -java.rmi.UnmarshalException: Return value not found; nested exception is:
    -java.lang.ClassNotFoundException
    -at sun/rmi/registry/RegistryImpl_Stub.lookup (RegistryImpl_Stub.java:109)
    -at java/rmi/Naming.lookup (Naming.java:60)
    -at client.main (client.java:9)
    client.java:9 is:
    -ServerCommands SC = (ServerCommands) Naming.lookup("rmi://localhost:1099/Thing");
    also, the server side binding is:
    -CommandsImpl acct = new CommandsImpl();
    -Naming.rebind("rmi://localhost:1099/Thing", acct);
    i dunno if i am braindead or if there is something wrong here... i had read elsewhere about delclaring the registry location, if that makes sense... if that is the case, how do i do this?
    Thanks in advance!

    well, here we are again, talking to myself ;)
    anyways, i did take your advice and a updated my code... its a little slopyy, as i didn't really go back over it, but it runs and i get that same error... KoQ (the client) cannot run without the ServerCommands.class file being along side it... even if i copy it to the directory, java doesn't like it... the only way it works is if i run KoQ(client) and the server out of the same directory and they share the ServerCommands.class file... its pointless to have to have them both share that same file, because then the server must be the client as well, both running out of that same directory.... ahhhhhhh!
    here we are:
    import com.ms.wfc.app.Application;
    import java.io.*;
    import java.net.*;
    import java.rmi.Naming;
    import java.util.Properties;
    public class KoQ {
         public static void main(String args[])
              try {
                   ServerCommands server = (ServerCommands) Naming.lookup("rmi://localhost:1089/KoQ");
                   Application.run(new KoQLogin());
              }//end try
              catch (Exception e) {
                   e.printStackTrace();
                   Application.run(new KoQDisconnect());
              }//end catch
         }//end main
    }//end KoQ
    import java.rmi.Naming;
    import java.rmi.server.UnicastRemoteObject;
    import java.rmi.RemoteException;
    import java.rmi.registry.Registry;
    import java.io.*;
    public class Server extends UnicastRemoteObject implements ServerCommands {
         public Server() throws RemoteException {super();}
      public Character Login (String Username, String Password) throws RemoteException {
           try {
                File f = new File("c:\\KoQ\\Characters\\"+Username);
                if (f.exists()) {
                     FileInputStream fis = new FileInputStream(f);
                     ObjectInputStream ois = new ObjectInputStream(fis);
                     Character CHARACTER = (Character) ois.readObject();
                     if (CHARACTER.vfyLogin(Password)) {
                          return CHARACTER;
                     }//end if
                     else {
                          return null;
                     }//end else
                } //end if
                else {
                     return null;
                } //end else
           } //end try
           catch (Exception e){
                return null;
           } //end catch
      }//end login
      public boolean CreateCharacter(String Username, String Password) throws RemoteException {
           Character CHARACTER = new Character(Username, Password);
           //Check if character exists
           return saveObject(CHARACTER, "c:\\KoQ\\Characters\\"+Username);
      public boolean saveObject(Object obj, String dir)
              try {
                   File objSaver = new File(dir);
                   FileOutputStream fos = new FileOutputStream(objSaver);
                   ObjectOutputStream oos = new ObjectOutputStream(fos);
                   oos.writeObject(obj);
                   System.out.println("OK, file was made...");
                   return true;
              }//end try
              catch (Exception e) {
                   e.printStackTrace();
                   System.out.println("AHHHHHHH! obj Could not be saved!");
                   return false;
              }//end catch
         }//end caveCharacterInfo
      public  static void main(String args[]) {
        try {
          Registry r = java.rmi.registry.LocateRegistry.createRegistry(1089);
         ServerCommands obj = new Server();
    System.out.print("RMI rebinding...");
          Naming.rebind("//localhost:1089/KoQ", obj);
    System.out.println("complete");
          System.out.println("Server ready");
        }//end try
         catch (Exception e) {
              System.out.println("Server: exception:");
              e.printStackTrace();
              System.out.println("AHHHHHHHHHHHHHHHH!");
        }//end catch
      }//end main
    }//end Server
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    public interface ServerCommands extends Remote {
         Character Login (String Username, String Password) throws java.rmi.RemoteException;
         boolean CreateCharacter (String Username, String Password) throws java.rmi.RemoteException;
    }//end ServerCommands
    **************************************again i threw out the useless classes from here (Character.class, etc); does ANYONE have an idea? this has been a problem for days and i really would like to know what it wrong... i am sure it is a problem on my part, and maybe you can see my mistakes?
    Thanks...

  • RMI-Server "checks" when Client closes RMI-Connection

    Hi there!
    I hope somebody can help me...
    I'm developing a client/server application where my client calls a remote method and my server starts working (i.e. 5-7 minutes batch processing).
    Is there a way my server "gets informed", when RMI connection is closed (network failure, client closes)? In this situation the server should perform a rollback, delete generated files, etc.
    I don't know if there is thrown a exception inside the server method, which I can catch ....
    Any suggestion is welcome ..
    Best Regards
    Anton

    Thanks a lot, I will have a look at the tutorial.
    Initially my thoughts on this issue were:
    -) The Client-RMI call is made in an own Thread (There are several things to do before job processing can start on the remote machine).
    -) when the RMI call is processed, the thread gets blocked, so doesn't add load to the machine (hope so).
    -) RMI does the "alive-checking", when network connection fails the client can mark the job as failed. The called server should also do some rollback. So I do not have to implements callback-listeners to react on server callbacks
    -) But I'm worried about open connections, running out of socket resources and that there is no way to abort a endless running job.
    This is my first aproach to solve this problem, I would be very glad about any comment ...

  • The strangest RMI connection error

    Hi all,
    i have a client server application that uses RMI. The server has the following network configuration. It has 2 network interfaces.
    hostname iface IP netmask
    ====================================
    sakura e1000g0 203.126.56.80 255.255.255.224
    nc_apps5 e1000g1 10.224.100.18 255.255.0.0
    when the server application listens on 203.126.56.80 iface, the client
    has no problem establishing RMI connection from 10.224.10.122 netmask 255.255.0.0
    via a static route with a route in between.
    However when I switched the server over to 10.224.100.18, and connects from the same client ( no configuration change) , i get the error
    [Wed Oct 11 14:38:53 SGT 2006 darkstar] ERROR calling: NetworkTestClient.performTest() called: Naming.lookup() args: rmi://nc_apps5.ncc.shs.com.sg:10000/RMITest
    java.rmi.ConnectException: Connection refused to host: 10.224.10.122; nested exception is:
    java.net.ConnectException: Connection refused
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
    If anything the second scenario should work, because both the server and the client are in the subnet i.e 10.224.x.x. but it turns to be the opposite. Can anyone
    tell me what gives over here.
    Many Thanks in advance
    Henley from Singapore. National Cancer Center.

    Thanks for pointing that out. its not a mistake. I do not have access to the source of the application. However I am wondering why is the client trying to connect back to itself in the second scenario when its supposed to be connecting to 10.224.100.18. ip of the server.
    Its very strange because the connection was apparently successful when
    the the client tries to connect to 203.126.56.80. instead of 10.224.100.18 i.e no error.
    is there anycode in the RMI that says, if server is in the same ip as me, try connecting to myself first ?
    once again thanks in advance.

  • Help need to know about JSP-RMI connection

    Hi All...
    Can anyone send me any tutorial/link about JSP-RMI connection. I need to access a RMI server object from JSP page.Is it possible?
    Looking for your responds.....

    Hi ...
    I didn't get any reply from any one....
    Is it possible to make Java Server Pages and RMI work
    together -sure, jsp's can make requests to servlets which can then talk to remote objects, then a response can be sent back down to the jsp
    to invoke a method on a server object from a JSP? And
    if, does
    someone know of a good tutorial, article etc., on
    this matter?hmm, Google, JSP Tutorial, RMI Tutorial, etc.

  • RMI Connection Refused through Firewall

    Hi,
    I am having problems making an RMI connection through a firewall. On the server outside the firewall I have my servlet application running in an OC4J container and inside the firewall I have an EJB listening on port 6666. I have setup the firewall to allow connections through on port 6666. If I telnet from the machine outside the firewall on port 6666 I am able to make a connection to the EJB. So I know the firewall has been setup to handle the connection.
    I run the servlet application and when it tries to make the connection it gives an error:
    javax.naming.NamingException: Lookup error: java.net.ConnectException: Connection refused; nested exception is:
    java.net.ConnectException: Connection refused
    When I do a snoop on the external machine to see what data is trying to be sent to the internal machine there is no data. When doing the telnet test there was data.
    I have the same servlet application deployed on a machine internally and it is able to make a connection to the EJB. The only problem is either the configuration of the application server on the external machine or the firewall configuration.
    Anyone able to help me see what I am missing?
    Thanks
    Shawn Clark

    not sure what you mean by having a 'EJB listening' on port 6666. Do you mean actually having a socket listening within the EJB code? If so then that is a suspicious EJB activity.
    If not then i guess you mean the ORMI listening port of the OC4J application. This is normally set on port 23791 to allow the RMI communication to flow.
    -lp

  • RMI: connection refused error while invoking remote method from client mac.

    Hi All,
    when i run client program, which is calling remote object from other system, it shows the below error.
    please help me solving this issue, i also have policy file and installed security manager.
    Exception in Cliendjava.rmi.ConnectException: Connection refused to host: 10.66.
    112.137; nested exception is:
    java.net.ConnectException: Connection refused: connect
    thanks in advance.
    Regards,
    Anand.

    See item A.1 of the [RMI FAQ|http://java.sun.com/j2se/1.5.0/docs/guide/rmi/faq.html].

  • Issue in RMI connection from NW

    Hi All,
    We are working on SAP NW 7.0 connectivity to an external J2EE  application running on Websphere platform using RMI protocol. We are facing issues in connecting a Java application running on NW 7.0 to that external application.
    The EJB  of the external system is running on Web sphere and Java application on NW server is acting as ejb client. Web sphere is running on IBM JDK and NW is running on HP JDK.
    The application and connection works fine for some time and after some time the integration stops working and all further new requests do not go through. We found that the initial context look up stops working after some time. The JNDI Look up is the line where it gets stuck. Once we restart NW service again, things start working and stops again after some time.
    We are unable to identify the root cause of the issue.
    Thanks in advance.
    Shaila Krishna.

    Hi,
    Did you try increasing the number of connection at both ends?
    In SAP NW you can increase the number of connections in the jco connector.
    Regards,
    Vamshi.

  • RMI connectivity problem (multi-NIC)

    I'm developing a simple photo share program with Java RMI.
    I connect rmiregistry (192.168.100.3), it returns the object reference, but when I invoke a method I get problems.
    My server (remote) - 192.168.100.3 - reply with an address of another NIC - 192.168.62.1 (from VMware). I print out the Proxy object, and I was surprised when I saw 192.167.62.1 address, instead 192.168.100.3. My client is running on 192.168.100.1 address.
    Why is this happening?
    When I turned off the VMware virtual NICs, I was successful. I want to understand what is going on, and if is there a way to fix this issue.
    $ java rmi.Client
    Looking...object found!
    Proxy[PhotoShare,RemoteObjectInvocationHandler[UnicastRef [liveRef: [endpoint:[192.168.62.1:58343](remote),objID:[4cc5973e:11de2bb065b:-7fff, 4037313925566802436]]]]]
    Exception in thread "main" java.rmi.ConnectIOException: Exception creating connection to: 192.168.62.1; nested exception is:
         java.net.SocketException: Network is unreachable
         at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:614)
         at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
         at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
         at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:110)
         at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
         at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
         at $Proxy0.listaFotos(Unknown Source)
         at rmi.Client.main(Client.java:26)
    Caused by: java.net.SocketException: Network is unreachable
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
         at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
         at java.net.Socket.connect(Socket.java:519)
         at java.net.Socket.connect(Socket.java:469)
         at java.net.Socket.<init>(Socket.java:366)
         at java.net.Socket.<init>(Socket.java:180)
         at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
         at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
         at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
         ... 7 moreEdited by: pantony on Nov 28, 2008 3:26 AM
    Edited by: pantony on Nov 28, 2008 3:27 AM

    See item A.1 of the [RMI FAQ|http://java.sun.com/j2se/1.5.0/docs/guide/rmi/faq.html].

  • Rmi - connection aborted:socket write error

    Weblogic 5.1 is running on my localhost and a remote object successfully registered on the weblogic. There is an applet trying to establish a connection and after the client is registered in the client list I get the following exception
    Thu Jan 25 11:29:06 PST 2001:<E> <ServletContext-General> Servlet failed with Ex
    ception
    java.net.SocketException: Connection aborted by peer: socket write error
    at java.net.SocketOutputStream.socketWrite(Native Method)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:83)
    at weblogic.servlet.internal.ChunkUtils.writeChunks(ChunkUtils.java:88)
    at weblogic.servlet.internal.ServletOutputStreamImpl.flush(ServletOutput
    StreamImpl.java:121)
    at weblogic.servlet.internal.ServletOutputStreamImpl.writeStream(Servlet
    OutputStreamImpl.java:444)
    at weblogic.servlet.ClasspathServlet.sendResource(ClasspathServlet.java:
    114)
    at weblogic.servlet.ClasspathServlet.doGet(ClasspathServlet.java:87)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:105)
    at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
    textImpl.java:742)
    at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
    textImpl.java:686)
    at weblogic.servlet.internal.ServletContextManager.invokeServlet(Servlet
    ContextManager.java:247)
    at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.jav
    a:361)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    And the java console shows this message:
    java.lang.NoClassDefFoundError
    at weblogic/rmi/extensions/BasicRequest.init (BasicRequest.java)
    at weblogic/rmi/extensions/BasicRequest.<init> (BasicRequest.java:18)
    at weblogic/rmi/extensions/AbstractRemoteObjectReference.getRequest (AbstractRemoteObjectReference.java:71)
    at weblogic/jndi/internal/RemoteContextFactoryImpl_WLStub.getContext (RemoteContextFactoryImpl_WLStub.java:77)
    at weblogic/jndi/WLInitialContextFactoryDelegate.newRemoteContext (WLInitialContextFactoryDelegate.java:316)
    at weblogic/jndi/WLInitialContextFactoryDelegate.newContext (WLInitialContextFactoryDelegate.java:242)
    at weblogic/jndi/WLInitialContextFactoryDelegate.getInitialContext (WLInitialContextFactoryDelegate.java:205)
    at weblogic/jndi/Environment.getContext (Environment.java:122)
    at weblogic/jndi/Environment.getInitialContext (Environment.java:105)
    at weblogic/rmi/Naming.getContext (Naming.java:225)
    at weblogic/rmi/Naming.lookup (Naming.java:67)
    at AppletTest.init (AppletTest.java:30)
    at com/ms/applet/AppletPanel.securedCall0 (AppletPanel.java)
    at com/ms/applet/AppletPanel.securedCall (AppletPanel.java)
    at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
    at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
    at com/ms/applet/AppletPanel.run (AppletPanel.java)
    at java/lang/Thread.run (Thread.java
    Can someone help solve this problem.
    Thansk in advance,
    Nirmal R.

    The point where the failure occurs in in the initialization of the transaction framework, so I would guess that you do not have the plug-in for the applet.
    Nirmal R wrote:
    Weblogic 5.1 is running on my localhost and a remote object successfully registered on the weblogic. There is an applet trying to establish a connection and after the client is registered in the client list I get the following exception
    Thu Jan 25 11:29:06 PST 2001:<E> <ServletContext-General> Servlet failed with Ex
    ception
    java.net.SocketException: Connection aborted by peer: socket write error
    at java.net.SocketOutputStream.socketWrite(Native Method)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:83)
    at weblogic.servlet.internal.ChunkUtils.writeChunks(ChunkUtils.java:88)
    at weblogic.servlet.internal.ServletOutputStreamImpl.flush(ServletOutput
    StreamImpl.java:121)
    at weblogic.servlet.internal.ServletOutputStreamImpl.writeStream(Servlet
    OutputStreamImpl.java:444)
    at weblogic.servlet.ClasspathServlet.sendResource(ClasspathServlet.java:
    114)
    at weblogic.servlet.ClasspathServlet.doGet(ClasspathServlet.java:87)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:105)
    at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
    textImpl.java:742)
    at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
    textImpl.java:686)
    at weblogic.servlet.internal.ServletContextManager.invokeServlet(Servlet
    ContextManager.java:247)
    at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.jav
    a:361)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    And the java console shows this message:
    java.lang.NoClassDefFoundError
    at weblogic/rmi/extensions/BasicRequest.init (BasicRequest.java)
    at weblogic/rmi/extensions/BasicRequest.<init> (BasicRequest.java:18)
    at weblogic/rmi/extensions/AbstractRemoteObjectReference.getRequest (AbstractRemoteObjectReference.java:71)
    at weblogic/jndi/internal/RemoteContextFactoryImpl_WLStub.getContext (RemoteContextFactoryImpl_WLStub.java:77)
    at weblogic/jndi/WLInitialContextFactoryDelegate.newRemoteContext (WLInitialContextFactoryDelegate.java:316)
    at weblogic/jndi/WLInitialContextFactoryDelegate.newContext (WLInitialContextFactoryDelegate.java:242)
    at weblogic/jndi/WLInitialContextFactoryDelegate.getInitialContext (WLInitialContextFactoryDelegate.java:205)
    at weblogic/jndi/Environment.getContext (Environment.java:122)
    at weblogic/jndi/Environment.getInitialContext (Environment.java:105)
    at weblogic/rmi/Naming.getContext (Naming.java:225)
    at weblogic/rmi/Naming.lookup (Naming.java:67)
    at AppletTest.init (AppletTest.java:30)
    at com/ms/applet/AppletPanel.securedCall0 (AppletPanel.java)
    at com/ms/applet/AppletPanel.securedCall (AppletPanel.java)
    at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
    at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
    at com/ms/applet/AppletPanel.run (AppletPanel.java)
    at java/lang/Thread.run (Thread.java
    Can someone help solve this problem.
    Thansk in advance,
    Nirmal R.

  • RMI connection refused

    Hello to all,
    I have created and completed an RMI chat application and tested it on my localhost. It worked all right.
    Now I want to make it live i.e. run it through internet.
    Is it same as running on localhost only we have to change the IP address for locating registry.
    I have done that and uploaded the server file on host, also I have the IP address of that host.
    I have replaces localhost whit the give IP address but connection refused exception is thrown.
    I have located the registry on the server through IP address then when I use
    Registry reg=LocateRegistry("xx.xx.xx.xxx");
    System.out.println("1");
    chatAppIF chatStub=(chatAppIF)Naming.lookup("rmi://xx.xx.xx.xxx:xxxx/service");
    System.out.println("2");
    int i=chatStub.logMeIn(user,pass);
    System.out.println("3");Output screen shows
    1
    2
    Client exception: java.rmi.ConnectException: Connection refused to host: xx.xx.xx.xxx; nested exception is:
            java.net.ConnectException: Connection refused: connectWhile when i use
    Registry reg=LocateRegistry("xx.xx.xx.xxx");
    System.out.println("1");
    chatAppIF stub=(chatAppIF)reg.lookup("service");
    System.out.println("2");
    int i=chatStub.logMeIn(user,pass);
    System.out.println("3");it give output as
    1
    Client exception: java.rmi.ConnectException: Connection refused to host: xx.xx.xx.xxx; nested exception is:
            java.net.ConnectException: Connection refused: connectIs there is difference between naming.lookup() and reg.lookup() method?
    I think Naming.lookup() finds the registry but cannot find the method logMeIn() while reg.lookup() has no success.
    anyway why the connection is refused?

    The argument to Naming.bind()/rebind()/unbind() and Naming.lookup() is a URI of the form rmi://hostname[:port]/path.
    The argument to Registry.bind()/rebind()/unbind() and Registry.lookup() is just the path part.
    The data returned by Naming.list() is an array of URIs.
    The data returned by Registry.list() is an array of paths.
    In other words Naming.list() returns items which can be used as arguments to Naming.lookup(), and Registry.list() returns items which can be used as arguments to Registry.lookup().
    The reason is that when you construct a Registry, via LocateRegistry.getRegistry(), you supply the host and port at that point, so specifying it again in the bind/lookup string would be redundant. There's nothing stopping you doing that but the resulting name won't be compatible with what Naming.bind() would have done.

  • RMI connections performance

    I am having problems looking up a RMI object. The Weblogic console reports
    the following:
    Wed Apr 12 23:32:11 EDT 2000:<W> <ListenThread> Connection rejected:
    Login timed out after 5000 msec. The socket came from
    host=10.0.3.13,port=1140,localport=7001] See property
    weblogic.login.readTimeoutMillis.
    Wed Apr 12 23:32:22 EDT 2000:<W> <ListenThread> Connection rejected:
    Login timed out after 5000 msec. The socket came from
    host=10.0.3.13,port=1141,localport=7001] See property
    weblogic.login.readTimeoutMillis.
    Wed Apr 12 23:32:24 EDT 2000:<W> <ListenThread> Connection rejected:
    Login timed out after 5000 msec. The socket came from
    host=10.0.3.13,port=1143,localport=7001] See property
    weblogic.login.readTimeoutMillis.
    I get about 3 time out errors and it takes almost a full minute before the
    bind happens. The chunk of code that does the bind is included below:
    String rmiHostAndPort = "t3://localhost:7001/foo"
    System.out.println("Binding to " + rmiHostAndPort);
    IFoo foo =
    (IFoo) Naming.lookup(rmiHostAndPort);
    System.out.println("Bound to " + rmiHostAndPort);
    The time between "binding to" and "bound to" is slow. Sometimes, it does
    not even return at all. This happens when the applet is restarted for some
    obscure reason.
    Any help would be appreciated.
    Erik Currin
    [email protected]

    I am having problems looking up a RMI object. The Weblogic console reports
    the following:
    Wed Apr 12 23:32:11 EDT 2000:<W> <ListenThread> Connection rejected:
    Login timed out after 5000 msec. The socket came from
    host=10.0.3.13,port=1140,localport=7001] See property
    weblogic.login.readTimeoutMillis.
    Wed Apr 12 23:32:22 EDT 2000:<W> <ListenThread> Connection rejected:
    Login timed out after 5000 msec. The socket came from
    host=10.0.3.13,port=1141,localport=7001] See property
    weblogic.login.readTimeoutMillis.
    Wed Apr 12 23:32:24 EDT 2000:<W> <ListenThread> Connection rejected:
    Login timed out after 5000 msec. The socket came from
    host=10.0.3.13,port=1143,localport=7001] See property
    weblogic.login.readTimeoutMillis.
    I get about 3 time out errors and it takes almost a full minute before the
    bind happens. The chunk of code that does the bind is included below:
    String rmiHostAndPort = "t3://localhost:7001/foo"
    System.out.println("Binding to " + rmiHostAndPort);
    IFoo foo =
    (IFoo) Naming.lookup(rmiHostAndPort);
    System.out.println("Bound to " + rmiHostAndPort);
    The time between "binding to" and "bound to" is slow. Sometimes, it does
    not even return at all. This happens when the applet is restarted for some
    obscure reason.
    Any help would be appreciated.
    Erik Currin
    [email protected]

  • RMI Connect Exception

    I have a client server application,
    1) Server is running on a Linux Suse machine
    2) Client is running on a Windows 2000 machine
    I had been running this application for some time now, but now i started getting this weird problem.
    When i try to run the client i get this exception below:
    java.rmi.ConnectException: Connection refused to host: 127.0.0.2;
    and im unable to bring up the client.

    I'm inclined to doubt that a security policy error, especially on the client side, would given you such a general error. You't get an exception from the security manager instead.
    The "connection refused" is pretty much always down to not having a listener running on the port you're trying to connect to.
    Pinging uses a lower level of connection than TCP/IP so it doesn't tell you anything about ports being open. All it establishes is that the server's operating system is up and reachable.
    On unix you can use netstat to check what ports are being listened to by what tasks, don't know if you can do that on Windows. There's a netstat but I haven't explored the options.
    Agreed, it's probably not a problem with the code, it's more likely to be a problem with the scripts that start the server, or nameserver.

  • RMI - connection handling and parallelity

    Hello everybody!
    I have some questions about RMI that I was not able to clarify clearly enough through the documentation - maybe due to my poor english that hinders me to understand long technical documents ;-)
    Assumed I have a program that allows several users at the same time to connect to a server via RMI:
    - Will RMI be able to keep the different users apart? (So that a user will not get something that is determined for another)
    - Will RMI create Threads for the different tasks the different users want to execute? How does RMI handle threads?
    - What happens if 2 users want to acces the same object at the same time? Will RMI handle that or do I have to declare those methods/fields synchronized or something like that?
    Thank you in advance for your answers!

    - Will RMI be able to keep the different users apart? (So that a user will not get something that is determined for another)Yes.
    - Will RMI create Threads for the different tasks the different users want to execute? How does RMI handle threads?A new thread per connection. Connections are pooled at the client, so this doesn't imply a new thread per call.
    - What happens if 2 users want to acces the same object at the same time? Will RMI handle that or do I have to declare those methods/fields synchronized or something like that?It's up to you.

Maybe you are looking for