Can't run the "simple" (!) RMI example
Eric&Lisa Blische <[email protected]> Wed, 8 Nov 2006 21:37:57 -0500
| Newsgroups | gmane.comp.java.sun.rmi |
|---|---|
| Message-ID | <003801c703a8$13477e30$6501a8c0@D53HT441> |
Okay, I've spent two full days struggling with this. so its time to ask for help. I'm frustrated
beyond description, a migraine is killing me, and I cannot get the "simple" Hello RMI example
to run on my Windows XP.
I've perused numerous topics looking to see if the FAQ or other responses answer my question,
to no avail. I've seen the question come up many times in my scroll-through and searching.I'm using
Java 5 (jdk 1.5.0_09).
I am trying to receive my Sun Developer's certification and RMI is my weak spot !
hello-world.html states,
--------------------------------------------------------------------------------
Start the server
To start the server, run the Server class using the java command as follows:
On Windows platforms:
start java -classpath classDir example.hello.Server
where classDir is the root directory of the class file tree (see destDir in the section "Compiling the source files").
The output from the server should look like this:
Server ready
The server remains running until the process is terminated by the user (typically by killing the process).
--------------------------------------------------------------------------------
When I try it, it's not that easy ...
C:\Documents and Settings\Eric\Desktop\devexam\second_try\scjd\starting>java -classpath dist suncertify.remote.Server
Server exception: java.rmi.ServerError: Error occurred in server thread; nested exception is:
java.lang.NoClassDefFoundError: suncertify/remote/Hello
java.rmi.ServerError: Error occurred in server thread; nested exception is:
java.lang.NoClassDefFoundError: suncertify/remote/Hello
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:382)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
(...etc...)
Hello (a Java interface) and Server (implements Hello) are in the dist\ directory.
C:\Documents and Settings\Eric\Desktop\devexam\second_try\scjd\starting>dir dist\suncertify\remote
Volume in drive C has no label.
Volume Serial Number is 4487-E894
Directory of C:\Documents and Settings\Eric\Desktop\devexam\second_try\scjd\starting\dist\suncertify\remote
11/08/2006 07:59 PM <DIR> .
11/08/2006 07:59 PM <DIR> ..
11/08/2006 07:59 PM 962 Client.class
11/08/2006 07:59 PM 193 Hello.class
11/08/2006 07:59 PM 1,053 Server.class
4 File(s) 3,893 bytes
2 Dir(s) 39,750,754,304 bytes free
Okay, then bebopping around it seems I need to set a command line argument ... java.rmi.server.codebase. I've probably
tried about 100 variations on the file: protocol to get it to run (after starting up the registry, of course). There are many variations
in the old archives, none work for me though. I've tried things like,
java -Djava.rmi.server.codebase="file:/C:\Documents and Settings\Eric\Desktop\devexam\second_try\scjd\starting\dist\" suncertify.remote.Server
java -Djava.rmi.server.codebase="file://C:\Documents and Settings\Eric\Desktop\devexam\second_try\scjd\starting\dist\" suncertify.remote.Server
java -Djava.rmi.server.codebase="file:///C:\Documents and Settings\Eric\Desktop\devexam\second_try\scjd\starting\dist\" suncertify.remote.Server
java -Djava.rmi.server.codebase="file:/C:/Documents and Settings/Eric/Desktop/devexam/second_try/scjd/starting/dist/" suncertify.remote.Server
You get the picture. Endless permutations of forward and backward slashes, etc. I tried double-backslashes too. I either get
a java usage dump (with the back slashes) or a NoClassDefFound Error. I tried substituting %20's for the spaces in the file path.
When I added the -classpath, I get...
C:\Documents and Settings\Eric\Desktop\devexam\second_try\scjd\starting>java -Djava.rmi.server.codebase="file:/C:/Documents and Settings/Eric/Desktop/devexam/second_try/scjd/starting/dist/" -classpath dist suncertify.remote.Server
Server exception: java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
java.net.MalformedURLException: no protocol: and
java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
java.net.MalformedURLException: no protocol: and
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:217)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:343)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
at suncertify.remote.Server.main(Unknown Source)
Caused by: java.net.MalformedURLException: no protocol: and
at java.net.URL.<init>(URL.java:567)
at java.net.URL.<init>(URL.java:464)
at java.net.URL.<init>(URL.java:413)
at sun.rmi.server.LoaderHandler.pathToURLs(LoaderHandler.java:747)
at sun.rmi.server.LoaderHandler.getDefaultCodebaseURLs(LoaderHandler.java:120)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:149)
at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:215)
... 3 more
Which barks about the file protocol , I also have seen it unable to find the Hello class (compiled interface).
Anyone who can help me would have my eternal thanks and gratitude !
- Eric
===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS". For general help, send email to
[email protected] 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