RMI server invocation delay

Hello, I have a problem with server invocations. If I call the method that just prints to the console toString of passed MyClass instance, it takes 4.5 seconds.
If I pass String or null it works less than 10ms.
This problem appears only at the special environment.
Server should be at the Linux and client at the Windows.
The Client is an applet. This applet should be loaded from the Linux server.
But I have some Win computers that doesn't have this problem though they all are with XP and IE6.
Combinations like Linux-Linux, Windows-Linux, Windows-Windows work normal.
Besides if I even start this client from my IDE or just from my file system it works fast.
I can't even detect conditions which enough to reproduce this problem.
Here is my code:
TestServerIntf.java
public interface TestServerIntf extends Remote {
    void printMe(MyClass myClass) throws RemoteException;
}TestServer.java
public class TestServer implements TestServerIntf {
    public static void main(String[] args) {
        try {
            TestServerIntf engine = new TestServer();
            TestServerIntf stub =
                   (TestServerIntf) UnicastRemoteObject.exportObject(engine, 0);
            Registry registry = LocateRegistry.createRegistry(1099);
            registry.rebind("TestServer", stub);
            System.out.println("TestServer server bound");
        } catch (Exception e) {
            System.out.println("TestServer server exception:" + e.getMessage());
    public void printMe(MyClass myClass) throws RemoteException {
        System.out.println(myClass);
}TestClient.java
public class TestClient extends JApplet {
    private String host = "SERVER_HOST"; // specify here right host name
    private TestServerIntf server;
    public void init() {
        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                    createGUI();
        } catch (Exception e) {
            e.printStackTrace(); 
    private void createGUI() {
        try {
            Registry registry = LocateRegistry.getRegistry(host);
            server = (TestServerIntf) registry.lookup("TestServer");
        } catch (RemoteException e) {
             e.printStackTrace(); 
        } catch (NotBoundException e) {
             e.printStackTrace(); 
        final JLabel label = new JLabel();
        getContentPane().add(label, BorderLayout.CENTER);
        try {
            MyClass myClass = new MyClass();
            long t = System.currentTimeMillis();
            server.printMe(myClass);
            label.setText("PrintMe " + (System.currentTimeMillis() - t) + "ms!");
        } catch (RemoteException e1) {
             e1.printStackTrace(); 
}MyClass.java
public class MyClass implements Serializable {
}Besides if change the signature to "void printMe(Object object)" and pass "new MyClass[]{myClass}" than it takes 9 seconds! But "new MyClass[]{myClass1, myClass2}" takes also a 9 seconds.
I don't hope that you can reproduce this problem, but may be you have any ideas what is this problem connected with.
Please help.

Java does a reverse DNS lookup when you provide an IP address so DNS does come into it. I would say DNS is almost certainly the cause of the delay.

Similar Messages

  • Trying to call a method on an RMI server from a GUI

    Hi all, I'm new to the forums and I desperately need some help!
    My question fits into the RMI category but also the database/GUI side so sorry if this is posted in the wrong place.
    My application is a client/server system (programmed in Netbeans 6.8) that also uses GUIs and JDBC-ODBC. Basically, I am trying to call a method that adds an entry to my database from a GUI button.
    Due to the required RMI, I have the ServerInterface that extends Remote and I have a ServerImpl class that implements the Interface, and the RMI works fine so there is no problem there.
    My code for the button is:
    private void addUserActionPerformed(java.awt.event.ActionEvent evt) {                                       
    try{server.addNewUser("new");}
    catch(Exception e){}
    addUser.setText("buttonhaschanged");
    The server variable is declared above as ServerImpl server;
    The actual addNewUser method works fine when it is called explicitly via RMI in my main "Client" class, but this GUI is going to be like an "administrator GUI" that can manipulate the database, so there is no RMI involved here.
    Anyway, my button doesn't have any effect on the database, but the button changes text as desired so the button itself works, but it doesn't do what I want to the database, so I think my problem is the use of my "server" variable. I've tried making it static and I've tried making it of type ServerInterface, but no luck. Would I have to make the GUI class extend the interface too?
    Sorry for rambling on!
    Many thanks in advance
    David
    Edited by: DHD on Feb 26, 2010 6:15 AM

    Would I have to make the GUI class extend the interface too?Your GUI has nothing to do with the RMI. How did you obtaint the "server" ? have you looked in the RMI registry to get the stub object ?
    The second thing to notice is you are invoking a RMI calls on a EDT which you should not do it. Your RMI method calls should be invoked via SwingWorker-->doInBackground(); please take a look at the Java Doc
    [http://java.sun.com/javase/6/docs/api/javax/swing/SwingWorker.html|java Doc SwingWorker sample usage]
    You mentioned that the RMI method invocation works fine from the main class and not from the GUI so what did you do in the main class to get the stub do it in the doInBackground() method
    Regards,
    Alan
    London

  • RMI Server Offline Problem

    Hello all, I am e newbie in the world of RMI programming. I have developed an application that can control two devices over the internet. The code files are given below :
    Parallel.java
    import java.rmi.*;
    public interface Parallel extends Remote
         void relayDriver(byte k) throws RemoteException;
         byte currentStatus() throws RemoteException;
    ParallelImpl.java
    import parport.ParallelPort;
    import java.rmi.*;
    import java.rmi.server.*;
    public class ParallelImpl extends UnicastRemoteObject implements Parallel
         private Byte ctrlValue;
         ParallelPort lpt1 = new ParallelPort(0x378); // 0x378 is normally the base address for the LPT1 port
         public ParallelImpl(byte a) throws RemoteException
              ctrlValue = a;
              lpt1.write(ctrlValue);
              System.out.println("Device Actuation Code "+ctrlValue);
         public void relayDriver(byte k) throws RemoteException
              ctrlValue = k;
              System.out.println("Device Actuation Code "+ctrlValue);
              lpt1.write(ctrlValue);
         public byte currentStatus() throws RemoteException
    return ctrlValue;
    ParallelClient.Java
    import java.io.*;
    import java.rmi.*;
    import java.rmi.server.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ParallelClient extends JApplet implements ActionListener
         Byte g;
         String url = "rmi://169.254.196.149/";
         private Container container;
         private javax.swing.JTextArea resultArea;
         public void init()
              container = getContentPane();
              container.setLayout( new BorderLayout() );
              resultArea = new javax.swing.JTextArea();
              JRadioButton buttonZero = new JRadioButton("No Device
    On");
         buttonZero.setMnemonic(KeyEvent.VK_A);
         buttonZero.setActionCommand("0");
         buttonZero.setSelected(true);
         JRadioButton buttonOne = new JRadioButton("Device 1 On
    Only");
         buttonOne.setMnemonic(KeyEvent.VK_B);
         buttonOne.setActionCommand("1");
         JRadioButton buttonTwo = new JRadioButton("Device 2 On
    Only");
         buttonTwo.setMnemonic(KeyEvent.VK_C);
         buttonTwo.setActionCommand("2");
         JRadioButton buttonThree = new JRadioButton("Device 1
    and 2 Both On");
         buttonThree.setMnemonic(KeyEvent.VK_D);
         buttonThree.setActionCommand("3");
         //Group the radio buttons.
         ButtonGroup group = new ButtonGroup();
         group.add(buttonZero);
         group.add(buttonOne);
         group.add(buttonTwo);
         group.add(buttonThree);
         //Register a listener for the radio buttons.
         buttonZero.addActionListener(this);
         buttonOne.addActionListener(this);
         buttonTwo.addActionListener(this);
         buttonThree.addActionListener(this);
              JPanel radioPanel = new JPanel(new GridLayout(0, 1));
         radioPanel.add(buttonZero);
         radioPanel.add(buttonOne);
         radioPanel.add(buttonTwo);
         radioPanel.add(buttonThree);
         container.add(radioPanel, BorderLayout.LINE_START);
              container.add(resultArea, BorderLayout.SOUTH);
         public void actionPerformed(ActionEvent e)
              try
                   Parallel r1 = (Parallel)Naming.lookup(url +
    "inival");
                   if(r1.currentStatus()==0)
                             resultArea.setText("Previous
    Status: No Devices Online....");
                        else if(r1.currentStatus()==1)
                             resultArea.setText("Previous
    Status: Device 1 Online. Device 2 Offline.");
                        else if(r1.currentStatus()==2)
                             resultArea.setText("Previous
    Status: Device 2 Online. Device 1 Offline.");
                        else
                             resultArea.setText("Previous
    Status: Device 1 & 2 both are Online.");
                   g = Byte.parseByte(e.getActionCommand());
                   r1.relayDriver(g);
                   if(r1.currentStatus()==0)
                             resultArea.setText("Current
    Status: No Devices Online....");
                        else if(r1.currentStatus()==1)
                             resultArea.setText("Current
    Status: Device 1 Online. Device 2 Offline.");
                        else if(r1.currentStatus()==2)
                             resultArea.setText("Current
    Status: Device 2 Online. Device 1 Offline.");
                        else
                             resultArea.setText("Current
    Status: Device 1 & 2 both are Online.");
              catch(Exception et)
                   resultArea.setText("Server OffLine");
    ParallelServer.java
    import java.io.*;
    import java.rmi.*;
    import java.rmi.server.*;
    public class ParallelServer
         public static void main(String args[])
              try
                   System.out.println("Constructing Server Implementations ....");
                   ParallelImpl p1 = new ParallelImpl((byte)0);
                   System.out.println("Binding Server Implementation to registry ....");
                   Naming.rebind("inival",p1);
                   System.out.println("Waiting for invocations from Client ....");     
              catch(Exception e)
                   System.out.println("Server is Offline or Line has broken. Error : "+ e);
    The corresponding stub files, class files have been loaded on the internet. http://rcviproject.110mb.com/
    On the server machine the rmi registry is on and the ParallelServer program is also running. But when the applet at the URL is actuated then it shows 'server offline'. Why is this happening? Please help.

    That did not print anything. The server when started by the following commands :
    start rmiregistry
    start java ParallelServer
    continues to run at Waiting for invocation from client ...... no error msg is shown.
    do i need tomcat on the server machine in addition to this ?

  • Starting and stopping an RMI server

    I'm trying to figure out how to best stop and start my server.
    My server class has two executions. One for starting and one for stopping.
    Start Steps:
    1) create my remote object ( an extension of UnicastRemoteObject )
    2) create a registry ( LocateRegistry.create() )
    3) bind my remote object
    When I run this start method of my RMI server class, everything get's set up. I'm not doing any sort of waiting loop or anything to determine the lifecycle of my server. My understanding is that my rmiregistry, and my registered remote object, will continue to be available indefinitely. Perhaps this is incorrect.
    Stop Steps:
    When I want to stop the server, I'm calling my stop method. This is another invocation of my server class, so it's a separate JVM. In this stop method I want to do the following steps:
    1) get the registry that I created earlier, by port number
    2) get my remote object via reg.lookup()
    3) unbind my remote obect ( reg.unbind() )
    4) unexport my remote object ( UnicastRemoteObject.unexport ( myRemoteObj, true ) )
    My concerns here are whether this makes sense. Does the unexport method work like this? i.e. from a remote handle to the object -- I'm not in the local JVM when the stop method runs. Also, does the rmiregistry "just die" at this point? It's not holding anything and when my method exits there's no reference to it anywhere. Except maybe in client code . . .

    My understanding is that my rmiregistry, and my registered remote object, will continue to be available indefinitely. Perhaps this is incorrect.That's correct as long as you store static references to them both in the server JVM.
    My concerns here are whether this makes sense. Does the unexport method work like this? i.e. from a remote handle to the objectNo. You have to have the actual remote object. You could make shutdown() an RMI method itself.
    Also, does the rmiregistry "just die" at this point?No, you have to unexport that as well.

  • RMI server object getting garbage collected

    Hi all,
    I have seen a number of posts regarding the ConnectException and found that this can occur in a number of situations.
    I am having a problem here.
    I am having an RMI server that is always up and running. And the server object gets requests from the client at regular intervals. But, when the server object is not receiving any requests for a long time (ex: 1 day), then I think the remote object itself is getting garbage collected. And so, tough I am able to get the remote reference using the lookup method, I am getting "Connection refused to host: 192.168.0.216; nested exception is:
         java.net.ConnectException: Connection refused" when I call a method using this reference.
    I believe that this is because the server object getting garbage collected as there are no requests for the server since long. Please correct me if my assumption is wrong.
    I want to know, after how much time the server object gets garbage collected if no requests are received. But, my requirement is that the server object should always be available and WHENEVER a client request comes then that should be processed. What should I do to accomplish this task.
    If any one have any suggestions, please reply as soon as possible.
    Thanks in advance,
    srik4u

    You might do some research into using an activatable remote object. You run rmid (the rmi activation deamon) and register a subclass of java.rmi.activation.Activatable (instead of the usual UnicastRemoteObject) with it. With an activatable object, the remote reference to the activatable object doesn't need to have a live object behind it. If an activatable object is not running (ie: it hasn't been constructed yet, or it has been garbage collected ...as in your case) a remote reference to the object can still be exported to a client. The first time the client calls a method on the remote object, the activation service on the server sees the object is not active, and activates the object for the client. If the object is running ...it is rmi as usual. But if it gets gc'd again, the next invocation on the remote object will trigger the activation service again.
    (The above explanation paraphrases author David Flanagan from Java Enterprise in a Nutshell, O'Reilly)
    I have only built one of these, which loosely followed an example from the above mentioned book. It's a whole other ballgame over and above a regular rmi object. But like anything else, if you dig in and get your head wrapped around it, it eventually makes sense. Ok, why lie ...it confused the hell out of me and left me a little queasy. But you know the drill, by the time you build a few of them it will probably seem as easy as mapping the human genome, right? At any rate, it seems like what you might be after ...so have a look at it. Good luck, and wear your lifejacket.

  • RMI server causes the system to slow down and crash with socketException

    Hi,
    My RMI server application is a simple rmi server which invokes a JNI method once when I invoke through my client application. Server is left as it is after invoking the JNI method. After around 12 hours, server stops running with the following exception
    ZoneInfo: C:\Program Files\Java\jre1.6.0\lib\zi\ZoneInfoMappi
    ngs (Insufficient system resources exist to complete the requested service)
    ZoneInfo: C:\Program Files\Java\jre1.6.0\lib\zi\ZoneInfoMappings (Insufficient s
    ystem resources exist to complete the requested service)
    Dec 29, 2008 10:09:34 AM sun.rmi.transport.tcp.TCPTransport$AcceptLoop executeAc
    ceptLoop
    WARNING: RMI TCP Accept-0: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,por
    t=0,localport=2161] throws
    java.net.SocketException: socket closed
    at java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.net.PlainSocketImpl.accept(Unknown Source)
    at java.net.ServerSocket.implAccept(Unknown Source)
    at java.net.ServerSocket.accept(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(Unkno
    wn Source)
    at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Dec 29, 2008 10:10:35 AM sun.rmi.transport.tcp.TCPTransport$AcceptLoop executeAc
    ceptLoop
    WARNING: RMI TCP Accept-0: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,por
    t=0,localport=2161] throws
    java.net.SocketException: socket closed
    at java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.net.PlainSocketImpl.accept(Unknown Source)
    at java.net.ServerSocket.implAccept(Unknown Source)
    at java.net.ServerSocket.accept(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(Unkno
    wn Source)
    at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Dec 29, 2008 10:12:36 AM sun.rmi.transport.tcp.TCPTransport$AcceptLoop executeAc
    ceptLoop
    WARNING: RMI TCP Accept-0: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,por
    t=0,localport=2161] throws
    java.net.SocketException: socket closed
    at java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.net.PlainSocketImpl.accept(Unknown Source)
    at java.net.ServerSocket.implAccept(Unknown Source)
    at java.net.ServerSocket.accept(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(Unkno
    wn Source)
    at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Dec 29, 2008 10:15:37 AM sun.rmi.transport.tcp.TCPTransport$AcceptLoop executeAc
    ceptLoop
    WARNING: RMI TCP Accept-0: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,por
    t=0,localport=2161] throws
    java.net.SocketException: socket closed
    at java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.net.PlainSocketImpl.accept(Unknown Source)
    at java.net.ServerSocket.implAccept(Unknown Source)
    at java.net.ServerSocket.accept(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(Unkno
    wn Source)
    at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Dec 29, 2008 10:20:40 AM sun.rmi.transport.tcp.TCPTransport$AcceptLoop executeAc
    ceptLoop
    WARNING: RMI TCP Accept-0: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,por
    t=0,localport=2161] throws
    java.net.SocketException: socket closed
    at java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.net.PlainSocketImpl.accept(Unknown Source)
    at java.net.ServerSocket.implAccept(Unknown Source)
    at java.net.ServerSocket.accept(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(Unkno
    wn Source)
    at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    # An unexpected error has been detected by Java Runtime Environment:
    # Internal Error (4D555445583F57494E13120E4350500075), pid=1352, tid=1828
    # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode, sharing)
    # Can not save log file, dump to screen..
    # An unexpected error has been detected by Java Runtime Environment:
    # Internal Error (4D555445583F57494E13120E4350500075), pid=1352, tid=1828
    # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode, sharing)
    # If you would like to submit a bug report, please visit:
    # http://java.sun.com/webapps/bugreport/crash.jsp
    Does anyone has any idea?
    Regards
    Nidhin

    Your RMI server invokes a JNI method as you mentioned. It seems your system resource is become very low as from the exception from "ZoneInfoMappi"
    (Insufficient system resources exist to complete the requested service...I would suggest the following
    1- remove the JNI method invocation and replace by a simple method which does nothing special ( counting etc..)
    2- Run the RMI sever and stress test it again
    If you see the RMI server is working well after 12 hours, then your native method is leaking i.e consuming the system resources ( RAM etc..)
    You should profile the running RMI server using jconsole
    Regards,
    Alan Mehio

  • Can a RMI Server trap an exit event of its client  ?

    Hi all,
    Can a RMI Server trap an exit event of its client ??
    For example
    If I close the client using Ctrl-C, can the Server known what one of its client is closed ??

    You could consider allocating a new remote object per client via some login object. In my book I called this the 'remote session' pattern. That way each client can have its own server-side context, i.e. like an EJB session bean, which can have its own advantages. In fact if you're interested in when a specific client disappears, you must already have some client context so this is a clean solution to that as well.
    Then the session object can use the Unreferenced technique to know when the client has gone away unexpectedly, albeit with a 10 minute delay. This can be tuned via the java.rmi.dgc.leaseValue setting at the server. This works because each session object only has one client.
    If you can't do this and you can't control the client code, I'm not aware of any other solution under RMI.
    Except that as a last resort you could do something really fancy with custom socket factories at both ends that both implement a special ping protocol I suppose, but this is getting pretty hairy and you'd need to understand the RMI wire protocol to make it work.

  • How to keep track of client in rmi server

    how can I keep track of a disconnected client in a rmi server ?
    And what logic do I use to disconnect a client fro mthe server ?

    When a RMI client receives a stub to the remote object, RMI client runtime sends a dirty() call to the RMI server runtime which in turn helps the RMI server runtime in updating the client references to the remote object. Client reference is nothing but a unique identification generated by client RMI runtime for that instance of JVM. RMI uses a reference counting algorithm for destroying unreferenced remote objects. Once all references (all clients who are holding the stub to this remote object) to a remote object drops to zero, local garbage collector takes care of freeing this remote object.
    RMI client runtime initiates a TCP connection with the remote object only when a method is invoked on the stub. RMI transport layer uses a simple connection pooling mechanism to use already established TCP connections with server objects in further remote method invocations. Let's say the client is invoking a remote method on the remote object's stub fetched from the registry service. Now RMI transport layer initiates a TCP connection with the remote object (exported at ("host1", 4567)). After completion of the remote method, RMI client's transport layer keeps the connection open for some time (some configurable value) to take the advantage of the already established TCP connection in future remote method invocations on remote objects exported on the same host and port ("Host1", 4567"). RMI transport layer also takes care of closing these connections if the connections are idle more than configured value of connection open time.
    From the RMI server's perspective, once the RMI server runtime receives a remote method invocation request from the RMI client, it creates a new thread and try to dispatch the method on the designated remote object. After returning the results of the remote method to the client, RMI client's transport layer may not end this conservation with this remote object to take the advantage of this TCP connection in future remote method invocations. So the same thread may be used for dispatching another remote method in future. This is actually the side effect of re-using the established TCP connections on the client side.
    RMI server maintains client's reference in the client's reference set of the remote object as long as the client holds a normal reference to remote object's stub in its JVM. Once the client relinquishes the reference to the stub (goes out of the scope or setting it to the null), RMI client automatically sends clean() call to the RMI server runtime to update client reference set of the remote object. There is no public API to lookup or manipulate the client references for a given remote object, but you can always unexport the remote object even some clients are holding stubs to the remote object. Next time when the client invokes the remote method using this stub, client will receive a "connection refused exception" from the server because the remote object is already unexported. Let's say if the RMI server is started again (remote object is exported and registered with registry service), the client once again obtains the stub to the remote object from the registry service instead of using earlier stale stub. (This time remote object may have been exported on different port, so the port details in the old stub may not be valid any more).
    At any point of time there can be more than one established TCP connection with the RMI client. This may be the temporary condition; RMI client's transport layer automatically closes these connections if it does not receive any remote method invocation requests with in a pre-determined interval of time (default: 2 min). You can always find out RMI client's host in a given remote invocation by using getClientHost(), but how can you semantically define a "disconnected client in a rmi server" in your application context ? You can always force all the clients to fetch the stub again in future remote method invocations by unexporting the remote object in RMI server. I hope this information helps ...
    -- Srinath Mandalapu

  • RMI Server Object Pooling

    Hello All,
    Does WLServer6.1 take care of having a pool of RMI Server objects, similar
    to the way EJB container does it for EJBs. I guess what I am trying to
    achieve is an effect of Servlets that spawn light threads per invocation
    though now using RMI Server Object. I did look at the "executeThreadPool"
    options which would allow for increasing performance. I am not 100%
    satisfied with it though. Is there any way I can do this. Thanks,
    Chirag

    "Pyung Yoon" <[email protected]> writes:
    MediatorInterface mediator = (MediatorInterface) java.rmi.Naming.lookup("rmi://localhost:7001/TestMediator);This implies JRMP which the server does not support. You need to use t3 or iiop.
    andy

  • Kill rmi server, but Naming.list still works

    Hi,
    i have built an rmi server program, which creates some remote objects and a program which lists them. However, the program still lists the objects after the server has shudown. Only as soon as i kill the rmiregistry, the listing stops. Why?
    import java.rmi.*;
    import java.rmi.server.*;
       This server program instantiates two remote objects,
       registers them with the naming service, and waits for
       clients to invoke methods on the remote objects.
    public class ProductServer2
       public static void main(String args[])
          try
             System.out.println
                ("Constructing server implementations...");
             ProductImpl p1
                = new ProductImpl("Blackwell Toaster");
             ProductImpl p2
                = new ProductImpl("ZapXpress Microwave Oven");
             System.out.println
                ("Binding server implementations to registry...");
             Naming.rebind("toaster2", p1);
             Naming.rebind("microwave2", p2);
             System.out.println
                ("Waiting for invocations from clients...");
          catch(Exception e)
             e.printStackTrace();
    }The following program lists the remote objects:
    import java.rmi.*;
    import java.rmi.server.*;
    public class ShowBindings
         public static void main(String[] args)
              try
                   String[] bindings= Naming.list("");
                   for (int i=0; i<bindings.length; i++)
                        System.out.println(bindings);               
              catch(Exception e)
                   e.printStackTrace();

    The RMI Registry holds references to remote objects. Your "list" goes against the Registry, not the remote objects.
    The Registry doesn't care what remote objects are alive or dead. That's not it's purpose.
    Use unbind() to remove references in the Registry before ending your server.

  • How to deploy simple RMI server WLS 7

    Hi,
    I understand that if I write a simple RMI server - not
    extending UnicastRemoteObject, no clustering or IIOP
    issues - I don't need to run an rmic program. I'm not
    clear, however, on what then gets deployed. Does the
    client get the interface or implementation class? And, in
    this simple case, no deployment descriptor configuration
    for RMI is required, correct? I seem to be making this
    harder than it's supposed to be ...
    Thanks, Garry

    Garry, WLS itself is a server , you dont need an additional RMI server. All you need is create an RMI object and bind it to the server JNDI (from the server side) , then your clients can lookup the RMI object via the JNDI and they will get the stubs to make method invocations on the RMI object.
    Check out documentation at :
    http://e-docs.bea.com/wls/docs81/rmi/rmi_api.html#1000008693

  • Oracle.oc4j.rmi.OracleRemoteException: Invocation error: java.lang.NoSuchMe

    Hi
    i write simple session EJB with simple helloworld method
    Iam using jdeveloper
    Jdeveloper gave option to write sample client to test above session bean
    When i run that client i got this exception
    Am i missing anything
    This is a kind of urgent
    Any help will be appreciated
    oracle.oc4j.rmi.OracleRemoteException: Invocation error: java.lang.NoSuchMethodException: ejb.SessionEJB.helloworld()
         at com.evermind.server.rmi.RMIConnection.handleExceptionFromMethodInvocation(RMIConnection.java:745)
         at com.evermind.server.rmi.RMIConnection.obtainRemoteMethodResponse(RMIConnection.java:705)
         at com.evermind.server.rmi.RMIConnection.invokeMethod(RMIConnection.java:697)
         at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:70)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:27)
         at com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(StatelessSessionRemoteInvocationHandler.java:43)
         at __Proxy1.helloworld(Unknown Source)
         at ejb.SessionEJBClient.main(SessionEJBClient.java:24)
         Nested exception is:
    java.lang.NoSuchMethodException: ejb.SessionEJB.helloworld()
         at java.lang.Class.getMethod(Class.java)
         at com.evermind.server.rmi.RMIConnection.readMethod(RMIConnection.java:492)
         at com.evermind.server.rmi.RMIConnection.handleMethodInvocation(RMIConnection.java:418)
         at com.evermind.server.rmi.RMIConnection.handleOrmiCommandRequest(RMIConnection.java:357)
         at com.evermind.server.rmi.RMIServerConnection.handleOrmiCommandRequest(RMIServerConnection.java:192)
         at com.evermind.server.rmi.RMIConnection.dispatchRequest(RMIConnection.java:325)
         at com.evermind.server.rmi.RMIConnection.processReceivedCommand(RMIConnection.java:275)
         at com.evermind.server.rmi.RMIConnection.listenForOrmiCommands(RMIConnection.java:236)
         at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:202)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:299)
         at java.lang.Thread.run(Thread.java:534)
    Process exited with exit code 0.

    java.lang.NoSuchMethodException: ejb.SessionEJB.helloworld()
    Check the method definition.
    Does the method have parameters?
    Is the method helloWorld?

  • Urgent Help Required For Starting RMI server from servlet.

    I am currently working on rmi project.
    I want to send request to remote machine(Web host) where my application is from desktop client .For that we are using RMI.
    I am writing servlet and inside it i am binding object to registry for rmi server.
    which will be deployed on remote server.
    code ....
    Registry reg;
    reg=LocateRegistry.createRegistry(1099);
    Server server=new Server("server");//class whose remote object to be accessed
    //extends unicast remote object.Implement ServerInt interface which extends Remote.
    reg.bind("server",server);
    When i am trying to access this object i am getting following exception.
    javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalExcepti
    on: error unmarshalling return; nested exception is:
            java.lang.ClassNotFoundException: ServerModule.ServerInt]
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(Unknown Source)
    at com.sun.jndi.toolkit.url.GenericURLContext.lookup(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at RequstReplication.main(RequstReplication.java:27)
    Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested excep
    tion is:
    java.lang.ClassNotFoundException: ServerModule.ServerInt
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    ... 4 more
    Caused by: java.lang.ClassNotFoundException: ServerModule.ServerInt
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at sun.rmi.server.LoaderHandler.loadProxyInterfaces(Unknown Source)
    at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
    at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
    at java.rmi.server.RMIClassLoader$2.loadProxyClass(Unknown Source)
    at java.rmi.server.RMIClassLoader.loadProxyClass(Unknown Source)
    at sun.rmi.server.MarshalInputStream.resolveProxyClass(Unknown Source)
    at java.io.ObjectInputStream.readProxyDesc(Unknown Source)
    at java.io.ObjectInputStream.readClassDesc(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    ... 5 more
    I can access naming enumeration of registry and object bound to it.
    by following program.I shows corect objects.
    Context namingContext=new InitialContext();
    NamingEnumeration<NameClassPair> e=namingContext.list("rmi:");
    while(e.hasMore())
    System.out.println(e.next().getName());
    While when i start RMI server from simple java program i can access these objects from registry.
    I am not getting what is problem problem.Is there any other way to send request?
    Plese give quick response.

    I am currently working on rmi project.
    I want to send request to remote machine(Web host) where my application is from desktop client .For that we are using RMI.
    I am writing servlet and inside it i am binding object to registry for rmi server.
    which will be deployed on remote server.
    code ....
    Registry reg;
    reg=LocateRegistry.createRegistry(1099);
    Server server=new Server("server");//class whose remote object to be accessed
    //extends unicast remote object.Implement ServerInt interface which extends Remote.
    reg.bind("server",server);
    When i am trying to access this object i am getting following exception.
    javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalExcepti
    on: error unmarshalling return; nested exception is:
            java.lang.ClassNotFoundException: ServerModule.ServerInt]
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(Unknown Source)
    at com.sun.jndi.toolkit.url.GenericURLContext.lookup(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at RequstReplication.main(RequstReplication.java:27)
    Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested excep
    tion is:
    java.lang.ClassNotFoundException: ServerModule.ServerInt
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    ... 4 more
    Caused by: java.lang.ClassNotFoundException: ServerModule.ServerInt
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at sun.rmi.server.LoaderHandler.loadProxyInterfaces(Unknown Source)
    at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
    at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
    at java.rmi.server.RMIClassLoader$2.loadProxyClass(Unknown Source)
    at java.rmi.server.RMIClassLoader.loadProxyClass(Unknown Source)
    at sun.rmi.server.MarshalInputStream.resolveProxyClass(Unknown Source)
    at java.io.ObjectInputStream.readProxyDesc(Unknown Source)
    at java.io.ObjectInputStream.readClassDesc(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    ... 5 more
    I can access naming enumeration of registry and object bound to it.
    by following program.I shows corect objects.
    Context namingContext=new InitialContext();
    NamingEnumeration<NameClassPair> e=namingContext.list("rmi:");
    while(e.hasMore())
    System.out.println(e.next().getName());
    While when i start RMI server from simple java program i can access these objects from registry.
    I am not getting what is problem problem.Is there any other way to send request?
    Plese give quick response.

  • Attempting to use SSL over RMI from a web application to a RMI server

    Hi,
    I am attempting to use SSL over RMI to a server. The client is the web
    application that is hosted on WebLogic and that attempts to connect to the
    server. There is no client or server verification at either the client or
    the server end. The code works outside of WebLogic 7/8 but has the following
    issues when running the web application inside weblogic:
    java.rmi.ConnectException: Connection refused to host: gkhanna1; nested
    exception is:
    java.net.ConnectException: Connection refused: connect
    java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:350)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:137)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:124)
    at java.net.Socket.<init>(Socket.java:268)
    at java.net.Socket.<init>(Socket.java:95)
    at
    sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketF
    actory.java:20)
    at
    sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketF
    actory.java:115)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:494)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:169)
    at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:313)
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    at java.rmi.Naming.lookup(Naming.java:79)
    at
    com.hyperion.css.spi.impl.ntlm.NTLMConnectionClient.initConnection(NTLMConne
    ctionClient.java:59)
    at
    com.hyperion.css.spi.impl.ntlm.NTLMConnectionClient.getUsers(NTLMConnectionC
    lient.java:197)
    at com.hyperion.css.CSSAPIImpl.getUsers(Unknown Source)
    at com.hyperion.css.CSSAPIImpl.initialize(Unknown Source)
    at com.hyperion.css.CSSAPIImpl.initialize(Unknown Source)
    at jsp_servlet._jsp._app1.__app1signin._jspService(__app1signin.java:133)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at
    weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(Servle
    tStubImpl.java:1058)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :401)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :445)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :306)
    at
    weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(W
    ebAppServletContext.java:5445)
    at
    weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
    r.java:780)
    at
    weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
    ntext.java:3105)
    at
    weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
    :2588)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
    The code at the client that initiates the connection:
    socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
    SSLSocket socket = (SSLSocket) socketFactory.createSocket(host, port);
    socket.setEnabledCipherSuites(CIPHERS);
    socket.setEnableSessionCreation(true);
    Any ideas?
    Thanks

    I don't see anything that indicates SSL was directly a factor in the
    failure.
    From the exception stack it looks like a more basic connectivity issue,
    maybe the URL for the
    RMI server is incorrect for some reason or the server was down.
    It looks like you are doing something like this:
    SSL client -> WLS server with servletA, servletA RMI client
    (com.hyperion.css) -> RMI server
    The connection failure appears to be the connection from servletA RMI client
    to the RMI server.
    Is that a correct picture?
    Tony
    "Gaurav Khanna" <[email protected]> wrote in message
    news:[email protected]...
    Hi,
    I am attempting to use SSL over RMI to a server. The client is the web
    application that is hosted on WebLogic and that attempts to connect to the
    server. There is no client or server verification at either the client or
    the server end. The code works outside of WebLogic 7/8 but has thefollowing
    issues when running the web application inside weblogic:
    java.rmi.ConnectException: Connection refused to host: gkhanna1; nested
    exception is:
    java.net.ConnectException: Connection refused: connect
    java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:350)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:137)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:124)
    at java.net.Socket.<init>(Socket.java:268)
    at java.net.Socket.<init>(Socket.java:95)
    at
    sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketF
    actory.java:20)
    at
    sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketF
    actory.java:115)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:494)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:169)
    at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:313)
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    at java.rmi.Naming.lookup(Naming.java:79)
    at
    com.hyperion.css.spi.impl.ntlm.NTLMConnectionClient.initConnection(NTLMConne
    ctionClient.java:59)
    at
    com.hyperion.css.spi.impl.ntlm.NTLMConnectionClient.getUsers(NTLMConnectionC
    lient.java:197)
    at com.hyperion.css.CSSAPIImpl.getUsers(Unknown Source)
    at com.hyperion.css.CSSAPIImpl.initialize(Unknown Source)
    at com.hyperion.css.CSSAPIImpl.initialize(Unknown Source)
    at jsp_servlet._jsp._app1.__app1signin._jspService(__app1signin.java:133)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at
    weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(Servle
    tStubImpl.java:1058)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :401)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :445)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :306)
    at
    weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(W
    ebAppServletContext.java:5445)
    at
    weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
    r.java:780)
    at
    weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
    ntext.java:3105)
    at
    weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
    :2588)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
    The code at the client that initiates the connection:
    socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
    SSLSocket socket = (SSLSocket) socketFactory.createSocket(host, port);
    socket.setEnabledCipherSuites(CIPHERS);
    socket.setEnableSessionCreation(true);
    Any ideas?
    Thanks

  • Error while registering RMI Server

    Hi
    I have a system connected to bradband with a static ip. I am planning to use this as the RMI server and any system connected to the internet as the client. Is this possible....?
    I tried to bind the name to the registry and I get the following error.
    C:\PROGRA~1\Java\jre1.5.0_06\bin>java -Djava.security.policy=policy HelloServer
    HelloServer error: Connection refused to host: 59.144.28.215; nested exception i
    s:
            java.net.ConnectException: Connection refused: connect
    java.rmi.ConnectException: Connection refused to host: 59.144.58.215; nested exc
    eption is:
            java.net.ConnectException: Connection refused: connect
            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)
            at sun.rmi.server.UnicastRef.newCall(Unknown Source)
            at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
            at java.rmi.Naming.rebind(Unknown Source)
            at HelloServer.main(HelloServer.java:18)
    Caused by: java.net.ConnectException: Connection refused: connect
            at java.net.PlainSocketImpl.socketConnect(Native Method)
            at java.net.PlainSocketImpl.doConnect(Unknown Source)
            at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
            at java.net.PlainSocketImpl.connect(Unknown Source)
            at java.net.SocksSocketImpl.connect(Unknown Source)
            at java.net.Socket.connect(Unknown Source)
            at java.net.Socket.connect(Unknown Source)
            at java.net.Socket.<init>(Unknown Source)
            at java.net.Socket.<init>(Unknown Source)
            at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
    ource)
            at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
    ource)
            ... 7 moreCan anyone help me by resolving this error.....

    what do you mean by intranet address?
    If you use some NAT device (e.g, DSL, cable) that it is likely you won't be able to access the registry using the external IP address. In such case you need to open the registry port in the firewall.

Maybe you are looking for

  • PackageMaker basic question

    Hi I am a newcomer to PackageMaker and need it to do something quite specific. There are two elements to the package: 1. A sampler instrument file (for Logic Pro) - this need to install to the user's home directory and I have figured this part out 2.

  • How to contact the author of an application on the iPhone AppStore?

    Is there a link on the iPhone AppStore to send questions or suggestions to the developer of an application? (If not, why isn't there one? )

  • I need java code for chating application

    i need java code for chating application. plz help me

  • SAP ROUTETAB PROBLEM

    Hi experts while configuring saprouter i am getting the error as given below. please give the exact entries which are to be given in SAPROUTTAB . trc file: "dev_rout", trc level: 3, release: "700" Tue Jul 22 12:00:13 2008 NiHsLInit: alloc host/serv b

  • Convert checked exception into unchecked exception

    Hi friends I am little confused, When deciding on checked exceptions vs. unchecked exceptions. I went through the net. they are telling that Use checked exceptions when the client code can take some useful recovery action based on information in exce