RMI: ClassNotFoundException


C

cdvr

I am trying to setup a basic client/server, in which the server
returns a List of Row objects. My directory structure is...

C:\code\bin\
server\
Server.class
client\
Client.class
data\
Row.class
RowCreator.class
DefaultRowCreator.class

The RowCreator interface extends the rmi.Remote interface and has one
method, createRows. DefaultRowCreator is a concrete implementation of
RowCreator. Row is the data object which gets returned in a List by
RowCreator.

The server looks like....

RowCreator creator = new TableDataCreator();
RowCreator stub = (RowCreator)
UnicastRemoteObject.exportObject(creator, 0);
Registry registry = LocateRegistry.getRegistry();
registry.bind("row_creator", stub);

So I have the classes all compiled, and I open a command prompt to the
"bin" directory.

c:\code\bin> start rmiregistry
c:\code\bin> java -claspath . server.Server

I get the following...
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: data.RowCreator
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:
385
)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:
4
66)
at sun.rmi.transport.tcp.TCPTransport
$ConnectionHandler.run(TCPTransport
..java:707)
at java.lang.Thread.run(Thread.java:595)
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.bind(Unknown Source)
at server.DefaultServer.setupRMI(DefaultServer.java:31)
at Main.main(Main.java:33)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments;
nested ex
ception is:
java.lang.ClassNotFoundException: data.RowCreator
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:
375
)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:
4
66)
at sun.rmi.transport.tcp.TCPTransport
$ConnectionHandler.run(TCPTransport
..java:707)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: data.RowCreator
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:
7
07)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:651)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:588)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:
6
28)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:
294
)
at
sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStrea
m.java:238)
at java.io_ObjectInputStream.readProxyDesc(ObjectInputStream.java:
1500)
at java.io_ObjectInputStream.readClassDesc(ObjectInputStream.java:
1463)
at java.io_ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:
1
699)
at java.io_ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io_ObjectInputStream.readObject(ObjectInputStream.java:348)
.... 9 more

Why can't it find data.RowCreator? It is definitely in there.

Thanks!
 
Ad

Advertisements

?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

cdvr said:
I am trying to setup a basic client/server, in which the server
returns a List of Row objects. My directory structure is...

C:\code\bin\
server\
Server.class
client\
Client.class
data\
Row.class
RowCreator.class
DefaultRowCreator.class

The RowCreator interface extends the rmi.Remote interface and has one
method, createRows. DefaultRowCreator is a concrete implementation of
RowCreator. Row is the data object which gets returned in a List by
RowCreator.

The server looks like....

RowCreator creator = new TableDataCreator();
RowCreator stub = (RowCreator)
UnicastRemoteObject.exportObject(creator, 0);
Registry registry = LocateRegistry.getRegistry();
registry.bind("row_creator", stub);

So I have the classes all compiled, and I open a command prompt to the
"bin" directory.

c:\code\bin> start rmiregistry
c:\code\bin> java -claspath . server.Server

I get the following...
java.rmi.ServerException: RemoteException occurred in server thread;
nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested
exception is:
java.lang.ClassNotFoundException: data.RowCreator
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java: 385)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments;
nested exception is:
java.lang.ClassNotFoundException: data.RowCreator
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)

Try:

start rmiregistry -J-classpath -J.

Arne
 
C

cdvr

Try:
start rmiregistry -J-classpath -J.

Arne- Hide quoted text -

Thanks that worked for the server.

I start the client like:

c:\code\bin> java -classpath . Client 192.168.1.101 1900

try {
Registry registry = LocateRegistry.getRegistry("192.168.1.101",
1900);
return (RowCreator) registry.lookup("row_creator");
} catch (Exception e) {
System.err.println(remoteName + " exception:");
e.printStackTrace();
}

Now the client gets

java.rmi.ConnectException: Connection refused to host: 192.168.1.101;
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.lookup(Unknown Source)
at client.ClientFrame.setupRMI(ClientFrame.java:146)
at client.ClientFrame.<init>(ClientFrame.java:61)
at Main$1.run(Main.java:44)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
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)

FYI, I am running the server and client on the same machine. When
running the client I tried changing from 192.168.1.101 to 127.0.0.1
and to localhost. Same error each time. Am I missing something?

thanks.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

cdvr said:
I start the client like:

c:\code\bin> java -classpath . Client 192.168.1.101 1900

try {
Registry registry = LocateRegistry.getRegistry("192.168.1.101",
1900);
return (RowCreator) registry.lookup("row_creator");
} catch (Exception e) {
System.err.println(remoteName + " exception:");
e.printStackTrace();
}

Now the client gets

java.rmi.ConnectException: Connection refused to host: 192.168.1.101;
nested exc
eption is:
java.net.ConnectException: Connection refused: connect

FYI, I am running the server and client on the same machine. When
running the client I tried changing from 192.168.1.101 to 127.0.0.1
and to localhost. Same error each time. Am I missing something?

Could be a software firewall blocking the port.

Arne
 
Ad

Advertisements

E

Esmond Pitt

cdvr said:
Registry registry = LocateRegistry.getRegistry("192.168.1.101", 1900);
Now the client gets

java.rmi.ConnectException: Connection refused to host: 192.168.1.101;

This means that either there is no Registry running at port 1900 of the
host 192.168.1.101, or there is a firewall in the way.
 
C

cdvr

This means that either there is no Registry running at port 1900 of the
host 192.168.1.101, or there is a firewall in the way.


Well I found out that something else was using port 1900, so I started
it on a different port. my next question is how can I bundle my app
as a jar such that is starts up rmiregistry for me instead of having
to have someone open up a command prompt, run rmiregistry, then open
another prompt and run the app. this is on windows by the way.

thanks
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

cdvr said:
Well I found out that something else was using port 1900, so I started
it on a different port.
:)

my next question is how can I bundle my app
as a jar such that is starts up rmiregistry for me instead of having
to have someone open up a command prompt, run rmiregistry, then open
another prompt and run the app.

Run the rmiregistry within your server app.

Arne
 
Ad

Advertisements

E

Esmond Pitt

cdvr said:
Well I found out that something else was using port 1900, so I started
it on a different port.

Something wrong with 1099? the default RMI Registry port? which has been
reserved for RMI by IANA for ten years?
my next question is how can I bundle my app
as a jar such that is starts up rmiregistry for me instead of having
to have someone open up a command prompt, run rmiregistry, then open
another prompt and run the app. this is on windows by the way.

java.rmi.registry.LocateRegistry.createRegistry()
 

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

Top