Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

RMI: ClassNotFoundException

Thread view: 
cdvr - 25 Mar 2007 03:25 GMT
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!
Arne Vajhøj - 25 Mar 2007 03:45 GMT
> I am trying to setup a basic client/server, in which the server
> returns a List of Row objects. My directory structure is...
[quoted text clipped - 35 lines]
> 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
cdvr - 25 Mar 2007 03:57 GMT
> 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.
Arne Vajhøj - 25 Mar 2007 04:25 GMT
> I start the client like:
>
[quoted text clipped - 15 lines]
> 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
cdvr - 26 Mar 2007 11:28 GMT
> Could be a software firewall blocking the port.
>
> Arne

still no luck, no firewall is running.  any other ideas?
Arne Vajhøj - 27 Mar 2007 00:42 GMT
>> Could be a software firewall blocking the port.
>
> still no luck, no firewall is running.  any other ideas?

No.

Arne
Esmond Pitt - 27 Mar 2007 02:05 GMT
>    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.
cdvr - 27 Mar 2007 03:40 GMT
> 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
Arne Vajhøj - 27 Mar 2007 03:59 GMT
>> 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.

Run the rmiregistry within your server app.

Arne
Esmond Pitt - 27 Mar 2007 05:52 GMT
> 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()


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.