RMI Objects Help

Discussion in 'Java' started by rajatag, Feb 3, 2007.

  1. rajatag

    rajatag Guest

    Hi,

    I'm having a little problem with compiling the RMI Stub. Getting the
    following error. Have attached all relevant source code below. Hope
    someone can help!

    Thanks,
    Rajat

    ERROR
    ======
    D:\Projects\TreeServer\TreeServer_Stub.java:6: class
    TreeServer.TreeServer_Stub must be declared abstract. It does not
    define java.lang.Object getChild(char, TreeServer.Nodes, short,
    java.lang.String) from interface TreeInterface.TreeInterface.
    public final class TreeServer_Stub

    ===========
    TreeServer.java
    ===========
    package TreeServer;

    import java.rmi.Naming;
    import java.rmi.RMISecurityManager;
    import java.rmi.RemoteException;
    import java.rmi.server.UnicastRemoteObject;

    import TreeInterface.*;

    public class TreeServer extends UnicastRemoteObject implements
    TreeInterface {
    static final long serialVersionUID = 10000;

    NodeManagement nm = new NodeManagement();

    public static void main(String[] args) {
    try {
    if (System.getSecurityManager() == null) {
    System.setSecurityManager(new RMISecurityManager());
    }
    TreeServer q = new TreeServer();
    Naming.rebind("rmi://localhost/TreeService", q); // sets the
    // handle
    System.out.println("Start Main RMI Server");
    } catch (RemoteException er) {
    System.out.println("Exception in Main RMI Server: " + er);
    } catch (Exception err) {
    System.out.println("Exception occurred: " + err);
    }
    }

    public TreeServer() throws RemoteException {
    // do the init here.
    super();
    }

    public Nodes getChild(char c, Nodes nod, short difficulty, String
    dictionary)
    throws RemoteException {
    return nm.getChild(c, nod, difficulty, dictionary);
    }
    }

    =============
    Nodes.java
    =============

    package TreeServer;

    public class Nodes{
    public char letter;

    public int first_Child_offset = 1000;

    public boolean isTerminal = true;

    public boolean isLastSibling = true;

    public int NodeNo;

    public Nodes() {

    }

    public Nodes(int NodeNo, char letter, boolean isTerminal,
    int first_Child_offset, boolean isLastSibling) {
    this.NodeNo = NodeNo;
    this.letter = letter;
    this.isLastSibling = isLastSibling;
    this.first_Child_offset = first_Child_offset;
    this.isLastSibling = isLastSibling;
    this.isTerminal = isTerminal;
    }
    }

    =================
    NodeManagement.java
    =================

    package TreeServer;

    import java.io.*;
    import java.util.*;

    public class NodeManagement {

    public NodeManagement() {
    }

    public Nodes getChild(char c, Nodes nod, short difficulty, String
    dictionary) {

    /// this returns a node object. code is just too big to paste here.
    }

    }

    =============
    TreeInterface.java
    =============

    package TreeInterface;

    import java.rmi.*;
    import TreeServer.*;

    public interface TreeInterface extends java.rmi.Remote {

    public Nodes getChild(char c, Nodes nod, short difficulty, String
    dictionary)
    throws RemoteException;
    }

    ============
    TreeClient.java
    ============

    package TreeClient;

    import java.rmi.*;

    import TreeInterface.*;
    import TreeServer.Nodes;

    public class TreeClient {
    TreeInterface rq;

    public TreeClient() {
    try {
    rq = (TreeInterface) Naming.lookup("rmi://localhost/TreeService");
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    public Nodes getChild(char c, Nodes nod, short difficulty, String
    dictionary) {
    try {
    return rq.getChild(c, nod, difficulty, dictionary);
    } catch (Exception e) {
    return (new Nodes());
    }
    }
    }
     
    rajatag, Feb 3, 2007
    #1
    1. Advertising

  2. rajatag

    jupiter Guest

    "rajatag" <> wrote in message
    news:...
    > Hi,
    >
    > I'm having a little problem with compiling the RMI Stub. Getting
    > the
    > following error. Have attached all relevant source code below.
    > Hope
    > someone can help!
    >
    > Thanks,
    > Rajat
    >
    > ERROR
    > ======
    > D:\Projects\TreeServer\TreeServer_Stub.java:6: class
    > TreeServer.TreeServer_Stub must be declared abstract. It does not
    > define java.lang.Object getChild(char, TreeServer.Nodes, short,
    > java.lang.String) from interface TreeInterface.TreeInterface.
    > public final class TreeServer_Stub
    >

    I don't know RMI, Rajat, but it appears as though TreeServer_Stub
    should be declared as abstract, not final. Yes, no?

    You either have to declare it as abstract or fulfill the contract
    of implementing the methods.

    I think.
     
    jupiter, Feb 4, 2007
    #2
    1. Advertising

  3. rajatag

    rajatag Guest

    Not sure about this .... seem to have implemented the methods as
    required.
     
    rajatag, Feb 4, 2007
    #3
  4. rajatag

    Patrick May Guest

    "rajatag" <> writes:
    > I'm having a little problem with compiling the RMI Stub.


    Can you move to Java 1.5 to eliminate the need for an explicit
    stub class?

    Regards,

    Patrick

    ------------------------------------------------------------------------
    S P Engineering, Inc. | Large scale, mission-critical, distributed OO
    | systems design and implementation.
    | (C++, Java, Common Lisp, Jini, middleware, SOA)
     
    Patrick May, Feb 4, 2007
    #4
  5. rajatag

    Lew Guest

    "rajatag" <> writes:
    >> I'm having a little problem with compiling the RMI Stub.


    Patrick May wrote:
    > Can you move to Java 1.5 to eliminate the need for an explicit
    > stub class?


    Java 5 is almost two-and-a-half years old. Java 6 is out. Java 1.3 has already
    passed its "End of Life". Java 1.4, over five years old, is next to go.

    Enterprises rush out to get the latest version of Windows, of MS development
    tools and the like. But they hang on to obsolete and moribund Java versions
    longer than the involved managers would keep their cars.

    - Lew
     
    Lew, Feb 4, 2007
    #5
  6. rajatag

    rajatag Guest

    Hi,

    We are using Java 1.5 .... The error comes up when try to run the rmic
    command

    Regards,
    Rajat
     
    rajatag, Feb 4, 2007
    #6
  7. rajatag

    rajatag Guest

    Hi,

    I solved the problem by transferring the Nodes class to outside the
    TreeServer package.

    Thanks!

    Regards,
    Rajat
     
    rajatag, Feb 4, 2007
    #7
  8. rajatag

    Esmond Pitt Guest

    rajatag wrote:

    > I solved the problem by transferring the Nodes class to outside the
    > TreeServer package.


    Actually you solved the problem by forcing TreeInterface.java to be
    recompiled. You had some date problem which made the out-of-date object
    file with the old definition of getChild() look to be newer than the source:

    old definition as per the compiler error message:

    Object getChild(char, TreeServer.Nodes, short,
    java.lang.String)

    new definition as per your source code:

    Nodes getChild(char c, Nodes nod, short difficulty, String
    dictionary)
     
    Esmond Pitt, Feb 4, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Buu Nguyen

    RMI, JINI or RMI/IIOP

    Buu Nguyen, Aug 25, 2004, in forum: Java
    Replies:
    1
    Views:
    567
    Sudsy
    Aug 25, 2004
  2. JScoobyCed

    RMI Vs RMI over IIOP

    JScoobyCed, Jan 28, 2005, in forum: Java
    Replies:
    1
    Views:
    742
    Dag Sunde
    Jan 28, 2005
  3. Jan Schulze
    Replies:
    1
    Views:
    571
    Esmond Pitt
    Mar 26, 2005
  4. steve
    Replies:
    0
    Views:
    770
    steve
    Jun 16, 2005
  5. 7stud
    Replies:
    11
    Views:
    699
    Dennis Lee Bieber
    Mar 20, 2007
Loading...

Share This Page