Kaneo71
Kaneo71

Reputation: 3

IDL Abstract Method Error

I am currently creating a program to take in a user registration and allow them to "buy" an ebook through Corba. The main error I am getting is this:

BookServant is not abstract and does not override abstract method storeUserDetails(UserDetails) in distBkOperations

The ebook.idl currently looks like the following:

module BookAny {

struct UserDetails {
    string name;
    string password;
};

struct BookDetails {
    string bookID;
    string title;
    string price;
};


interface distBk {
void storeUserDetails(in UserDetails myUserDetails);
any getUserDetails(in string name, out any myUserDetails);

void storeBookDetails(in BookDetails myBookDetails);
any getBookDetails(in string title, out any myBookDetails);
}; };

BookServant.java looks as follows:

    import java.io.*;
import java.util.*;
import BookAny.*;
import org.omg.CORBA.*;

public class BookServant implements distBkOperations{
    public static Hashtable hashtable;
    public static ORB orb;

public BookServant (org.omg.CORBA.ORB orb){
        hashtable = new Hashtable();
        this.orb=orb;
}

public void storeUserDetails (BookAny.UserDetails myUserDetails, AnyHolder password){

    Any pass = orb.create_any();

    myUserDetails.password="safepasswordlol";

    pass.insert_string(myUserDetails.password);

    password.value = pass;


    hashtable.put(myUserDetails.name, myUserDetails);
    System.out.println(myUserDetails.name + " You have registered and your password is  " +myUserDetails.password+myUserDetails.name);

}

public Any getUserDetails (String name, AnyHolder myUserDetails){

Any anyAB = orb.create_any();
try {
    UserDetails tempAddrBook = (UserDetails)hashtable.get(name);

    UserDetailsHelper.insert(anyAB, tempAddrBook);
    myUserDetails.value = anyAB;
}catch (Exception e) {
    System.err.println("Error E: "+e);
    e.printStackTrace(System.out);
    }
}


/*  public void getUserDetails (String name, org.omg.CORBA.AnyHolder myUserDetails){

Any anyAB = orb.create_any();
try {
    UserDetails tempAddrBook = (UserDetails)hashtable.get(name);

    UserDetailsHelper.insert(anyAB, tempAddrBook);
    myUserDetails.value = anyAB;
}catch (Exception e) {
    System.err.println("Error E: "+e);
    e.printStackTrace(System.out);
    }
}*/
}

I can generate the files from the IDL properly but when actually trying to compile the BookServant or BookServer.java I get the above error. I have tried changing the idl interface from void to any and still nothing. Any help would be appreciated!

Upvotes: 0

Views: 84

Answers (1)

Reimeus
Reimeus

Reputation: 159844

As the error indicates, your IDL file only has a single parameter in any of the storeUserDetails operations, i.e. drop the 2nd parameter in the Java code

@Override
public void storeUserDetails(BookAny.UserDetails myUserDetails) {

Upvotes: 0

Related Questions