Good people of Restlet-Land,

I'm using Restlet 2.0.3 JSE, including its built-in web server, in a small
standalone Java application. Having got a few resources working, my next
task is to serve a directory of static files from within a JAR file. As I
understand, I need to use the CLAP protocol for this, but my efforts in
getting it working have been unsuccessful. Explanation follows the code:

// Main.java:

public static void main(String[] args) throws Exception {
    Component component = new Component();
    component.getServers().add(Protocol.HTTP, 8080);
    component.getDefaultHost().attach("/myapp",
        new MyApplication());
    component.start();
}

// MyApplication.java:

public synchronized Restlet createInboundRoot() {
    this.authenticator = createAuthenticator();

    Router router = new Router(this.getContext());
    router.attach("/test", TestResource.class);

    authenticator.setNext(router);

    // initialize the static file server
    final Component component = new Component();
    component.getClients().add(Protocol.CLAP);
    component.getContext().getParameters().add("timeToLive", "0");
    final Directory dir = new Directory(
        getContext(),
        "clap://system/web/restlet_docs/schema/");
        dir.setDeeplyAccessible(true);
        dir.setListingAllowed(false);
        dir.setNegotiatingContent(false);
        router.attach("/schema", dir);

        ErrorFilter ef = new ErrorFilter(this.getContext());
        ef.setNext(authenticator);
        return ef;
}

Upon app launch, Restlet logs the following:

Nov 9, 2010 7:04:46 PM org.restlet.engine.Engine createHelper
WARNING: No available server connector supports the required protocols:
'CLAP' . Please add the JAR of a matching connector to your classpath.
Nov 9, 2010 7:04:46 PM org.restlet.engine.http.connector.HttpServerHelper
start
INFO: Starting the internal HTTP server on port 8080

A subsequent request to http://localhost:8080/myapp/schema/ results in a 404
as well as the following log output:

Nov 9, 2010 7:10:05 PM org.restlet.engine.component.ClientRouter getNext
WARNING: The protocol used by this request is not declared in the list of
client connectors. (CLAP)
Nov 9, 2010 7:10:05 PM org.restlet.engine.component.ClientRouter getNext
WARNING: The protocol used by this request is not declared in the list of
client connectors. (CLAP)
Nov 9, 2010 7:10:05 PM org.restlet.engine.local.DirectoryServerResource
getVariants
INFO: Getting variants for : clap://system/web/restlet_docs/schema/
Nov 9, 2010 7:10:05 PM org.restlet.engine.local.DirectoryServerResource
doInit
INFO: Converted target URI: clap://system/web/restlet_docs/schema/
Nov 9, 2010 7:10:05 PM org.restlet.engine.log.LogFilter afterHandle
INFO: 2010-11-09 19:10:05 0:0:0:0:0:0:0:1%0 - - 8080 GET /myapp/schema/ -
404

I have the following JARs in my classpath:
org.restlet.jar
org.restlet.ext.json.jar
org.restlet.ext.xml.jar
org.restlet.ext.velocity.jar

Am I missing something?

Regards,
Alex

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2680572

Reply via email to