Re: Class Server requests
Dave Brosius <[email protected]>
| Newsgroups | gmane.comp.java.sun.jini |
|---|---|
| Message-ID | <000901c72d06$6a0f26a0$6501a8c0@MeBigFatGuy> |
Aha! that makes sense. Altho a return of 404 for the '/' request, which is what i do, should then prompt the registrar, or whoever is asking for the class, to ask for individual class files. BTW, when serving individual classes, the first request is for: GET /META-INF/PREFERRED.LIST HTTP/1.1 To which i return 404, but was curious what jini was looking for. ----- Original Message ----- From: "Calum Shaw-Mackay" <[email protected]> To: "Dave Brosius" <[email protected]> Cc: <[email protected]> Sent: Sunday, December 31, 2006 12:59 PM Subject: Re: Class Server requests >> 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]