Hi there. To set the stage: I'm using restlet 1.0.4 embedded in a
servlet webapp. This is tested under Eclipse 3.2.1 using the built-in
J2EE tools (i.e. not MyEclipse), running on a Mac, with Tomcat
5.5.23. I can give even more details if you wish ;-)
I'm trying to use code like the following to host a bunch of .css
files. Because I had problems, I've been testing it with URLs like
"http://localhost:8080/foo/css/test.txt"
public class FooApplication extends Application {
public WikiBlogApplication(Context context) {
super(context);
}
@Override
public Restlet createRoot() {
Directory cssDirectory = new Directory(getContext(),
"war:///css");
cssDirectory.setListingAllowed(false);
cssDirectory.setDeeplyAccessible(true);
cssDirectory.setNegotiateContent(false);
Router router = new Router(getContext());
router.attach("/css", cssDirectory);
return router;
}
}
When I ask for "http://localhost:8080/foo/css/test.txt" I get a 404.
From debugging it, the following seems to be happening:
- a DirectoryResource is successfully created which contains the
contents of "war:///css/test.txt" ("Hello") and has a list of
variants which matches the contents of "war:///css/test.txt" (a URI
list of "/css/test.txt"). This is assigned to target on Finder.java:268
- target.handleGet() is called.
- Down within the call stack a DirectoryResource.getVariantsReferences
() call is made. Within this call, this.targetUri is "war:///css/
test.txt".
- contextResponse is assigned within here on line 559. The entity
("Hello") is then used as the contents of a ReferenceList(). This
seems wrong.
- ultimately the 'base' of "Hello" does not equal the baseName (line
584) and it is discarded as a variant, meaning getVariantsReferences
() return an empty list.
- however this is hidden in getVariants(). There is code at line
473/474 that looks like it could handle this case (it takes the
variant from this.fileContent), but the other path has already been
taken because this.directoryContent was non-null
- passed this point the lack of variants gets turned into a 404.
Whew. Now, am I barking up the wrong tree with my code and/or
interpretation, or is this a bug?
--
Mike Moran http://houseofmoran.com/