In hopes of preventing someone else from stumbles into the same table leg I hit...
Context:
I was trying to create small worker, filter, event handler, etc. classes on an RMI
client, pick one at runtime, send it to the server, have the server execute it against
some data/objects on it's end, and send the results back to me.
The problem:
The class ID and any state information gets automagically sent from the client to the
server (neat-o), but the program still fails with ClassNotFound exceptions. (bummer)
The cause:
Although RMI sends the class ID without any special effort on my part, I must specify
a codebase (to accompany the class ID) so the server knows where to go to get the
class definition itself. This codebase is specified via the following VM arg:
-Djava.rmi.server.codebase=...
The tricky/irksome part is that if I forget to specify the codebase, or make a tiny
mistake in syntax, I am simply given "ClassNotFound" exceptions with no further hint
as to what the problem is. I suppose it's a security thing, but it's still quite
annoying.
So much for the context. Now for the useful tip:
(1) The codebase may take the form of an HTTP or FILE URL. Contrary to popular
belief, an HTTP server is optional... it is not necessary for dynamic class loading
via RMI... and, in a development / unit testing environment, it is one more piece I'd
rather not bother with.
Example of a valid file-URL codebase:
-Djava.rmi.server.codebase=file://c:/JProjects/Products/Components/Test/build/
(2) The codebase must either point to a jar (end it ".jar") or a directory (end in a
"/")
In other words, the following will fail (with our friend ClassNotFound)...
-Djava.rmi.server.codebase=file://c:/JProjects/Products/Components/Test/build
...and one can waste lots of time trying different permutations before noticing the
missing slash. I know I did.
--Ken
"If others have seen further than me, it is because giants were standing on my
shoulders"
_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org