logo       

newb question: packages w/rmi: msg#00005

java.sun.rmi

Subject: newb question: packages w/rmi

I'm trying to modify some example files to be inside of packages, but I'm
having a problem with the generated stub file. Here is the error I get when
running "java rmis.server":
Hello Server failed: java.rmi.StubNotFoundException: Stub class not found:
rmis.Hello_Stub; nested exception is:

java.lang.ClassNotFoundException: rmis.Hello_Stub

Can anyone tell me what I'm doing wrong? Do I have to specify a package when
generating the stub with rmic? If so, how? FYI: The files work fine when not
inside of packages (with the package reference removed from server.java).

Thanks,

Steve


HelloInterface.java:
package rmis;
import java.rmi.*;
public interface HelloInterface extends Remote {
public String sayHello() throws RemoteException;
public String sayGoodbye() throws RemoteException;
}

server.java:
package rmis;

import java.rmi.*;

public class server {

public static void main (String[] argv) {
try {
Naming.rebind ("Hello", new rmis.Hello());
System.out.println ("Hello Server is ready.");
} catch (Exception e) {
System.out.println ("Hello Server failed: " + e);
}
}
}

Hello.java
package rmis;

import java.rmi.*;
import java.rmi.server.*;

public class Hello extends UnicastRemoteObject implements rmis.HelloInterface
{
private String helloMsg, goodbyeMsg;
private static final String szDefaultHelloMsg = "Default Hi!";
private static final String szDefaultGoodbyeMsg = "Default Bye!";

public Hello () throws RemoteException {
helloMsg = szDefaultHelloMsg;
goodbyeMsg = szDefaultGoodbyeMsg;
}

public Hello (String p_szHelloMsg, String p_szGoodbyeMsg) throws
RemoteException {
if ( p_szHelloMsg.length() > 0 )
helloMsg = p_szHelloMsg;
else
helloMsg = szDefaultHelloMsg;

if ( p_szGoodbyeMsg.length() > 0 )
goodbyeMsg = p_szGoodbyeMsg;
else
goodbyeMsg = szDefaultGoodbyeMsg;
}

public String sayHello() throws RemoteException {
return helloMsg;
}

public String sayGoodbye() throws RemoteException {
return goodbyeMsg;
}
}

===========================================================================
To unsubscribe, send email to listserv@xxxxxxxxxxxx and include in the body
of the message "signoff RMI-USERS". For general help, send email to
listserv@xxxxxxxxxxxx and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise