RMI question

J

Joshua Long

Hi, Im running a 2GHz PC with Suns JDK 1.4.2_something

Im trying to get the simplest of code to work in RMI and I just can'r seem
to make it happen::

I would appreciate if you could tell me what I'm (obviously) missing in
order ot get this to work -- thanks again.

Josh

//client code
package rtest ;
import java.rmi.Naming;
public class GreeterClient {
public static void main (String[] args ){
try {
RemoteGreeter rp = (RemoteGreeter) Naming.lookup (
RemoteGreeter.LOOKUP) ;
String random = rp.greet() ;
System.out.println( "Random phrase of the day is: " +random ) ;

} catch ( Exception exception ){
exception.printStackTrace();
}
}
}

// the Remote interface
package rtest ;
import java.rmi.*;
public interface RemoteGreeter
extends Remote
{
public String greet() throws RemoteException ;
public static final String LOOKUP = "RemoteGreeter" ;
}

// the server
package rtest ;
import java.rmi.Naming;
public class GreeterServer {
public static void main (String [] args ){
try {
RemoteGreeterImpl g_server = new RemoteGreeterImpl() ;
System.out.println ( "GreeterServer starting" );
Naming.rebind( RemoteGreeter.LOOKUP,g_server);
} catch ( Exception exception ){
exception.printStackTrace();
}
}
}

// the Remote implementation
package rtest ;
import java.rmi.server.*;
import java.rmi.RemoteException;

public class RemoteGreeterImpl
extends UnicastRemoteObject
implements RemoteGreeter
{
private static final String [] phrases = { "Buon giorno!" , "Salut!" ,
"Buena dias" ,"Allo", "Bonjour" } ;
protected RemoteGreeterImpl() throws RemoteException {
super() ;
}
public String greet() throws RemoteException {
int max = phrases.length ;
int i = (int) (Math.random() * ( max ) );
String rend = phrases ;
return rend ;
}
}


I run the commands
start rmiregistry
rmic -classpath ./bin -d ./bin -keep rtest.RemoteGreeterImpl
java -cp bin rtest.GreeterServer

and I get a whole deluge of exceptions, namely:

Can anyone get this to work? Im convinced it isnt my computer as it doesnt
work at the office, either..


C:\DOCUME~1\JOSHLO~1\Desktop\rmi>java -cp bin rtest.GreeterServer
GreeterServer starting
java.rmi.ServerException: RemoteException occurred in server thread; nested
exce
ption is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested
excep
tion is:
java.lang.ClassNotFoundException: rtest.RemoteGreeterImpl_Stub
at
sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:352
)
at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:207)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
..java:701)
at java.lang.Thread.run(Thread.java:534)
at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknow
n Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at rtest.GreeterServer.main(GreeterServer.java:12)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments;
nested ex
ception is:
java.lang.ClassNotFoundException: rtest.RemoteGreeterImpl_Stub
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at
sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:342
)
at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:207)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
..java:701)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.ClassNotFoundException: rtest.RemoteGreeterImpl_Stub
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:430)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
at
java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:631)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:257)
at
sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.jav
a:200)
at
java.io_ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:151
3)
at
java.io_ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at
java.io_ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
626)
at
java.io_ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io_ObjectInputStream.readObject(ObjectInputStream.java:324)
... 9 more
C:\DOCUME~1\JOSHLO~1\Desktop\rmi>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top