Re: Class Server requests

Calum Shaw-Mackay <[email protected]>
Newsgroups gmane.comp.java.sun.jini
Message-ID <[email protected]>
> Yup, and jini should do the same, it's no burden. If it really wants to be
> that persnickety, it should throw an
> URISyntaxException or similar exception if it finds an unruly codebase
> specification.

May I make a small interjection here.....this is not a Jini issue,
it's actually a URLClassLoader Issue (i.e J2SE) and there are a couple
of good reasons for it....

if the codebase (or if you are using a straight URLClassLoader outside
of jini) has a trailing slash, the name of the class is appended to
the URL request by the URL ClassLoader i.e. com.foo.Bar in
http://localhost:8080/ would actually be expanded to.....
http://localhost:8080/com/foo/Bar.class and each individual class
would result in a request to the Class Servert

However, if you don't add the trailing slash, URLClassLoader assumes
that the request points to a Zip/Jar File that the classloader can
download as a single entity then open a Jar Input Stream on which then
retrieves com/foo/Bar.class, thus meaning that for all classes in that
jar file, the download only has to occur once, and then can be
resolved locally from the downloaded file from then on, thus jars are
more efficient from a transport cost point of view.

In your first post the URLClassLoader is trying to open a file as
pointed to your codebase, which at the time had no trailing slash
indicating that the URLClassLoader would expect a JarFile as a
response, which is wasn't getting, thus causing your errors. By adding
the trailign slash you placed the URL ClassLoader into what is
commonly referred to as 'Directory Mode', and would thus append the
actual classnames to the HTTP request, which then caused it to work.

In fact if your classserver is running in verbose mode, you should see
each class being requested separately.

So to cut a very long story quite short; appending the trailing slash
significantly affects the operation of URLClassLoader.

Hope this clarifies the situation

BTW, I'd like to wish everyone a happy and prosperous new year.

--Calum

--------------------------------------------------------------------------
Getting Started:     http://www.jini.org/wiki/Category:Getting_Started
Community Web Site:  http://jini.org
jini-users Archive:  http://archives.java.sun.com/archives/jini-users.html
Unsubscribing:       email "signoff JINI-USERS"  to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.