Hello Alex,

the main message is the following:
WARNING: The protocol used by this request is not declared in the list of
client connectors. (CLAP)

A component declares a list of server (such as HTTP) and client connectors
(could be HTTP, CLAP, FILE, etc) which are used by the hosted applications,
restlets, server resources, etc. (see
http://wiki.restlet.org/docs_2.0/378-restlet.html).

In your case, you declare a server HTTP connector listening on port 8080 =>
component.getServers().add(Protocol.HTTP, 8080);
And at the same time, you need to complete the list client protocols, by
adding the CLAP one. As the org.restlet.jar contains an implementation of
this client connector, you are not required to complete your application's
classpath, so this is the only required instruction.

Having said that, you seem to follow this piece of advice since, in your
application, you define a Component that effectively declares the client
CLAP connector. But, there is no link between this component and the
Directory.
When an instance of the Directory is created, it is given a Context, in this
case inherited from the application (Application#getContext()):
final Directory dir = new Directory(getContext(),
"clap://system/web/restlet_docs/schema/");

This context is actually created by the Component, ie the one that attaches
your application. So I suggest that you remove the following instructions
from the Application code:
final Component component = new Component();
component.getClients().add(Protocol.CLAP);

And complete the definition of the single Component:
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8080);
component.getClients().add(Protocol.CLAP);
component.getDefaultHost().attach("/myapp",new MyApplication());

Best regards,
Thierry Boileau
ps : you can use the application class loader instead of the one of the
system
final Directory dir = new Directory(getContext(),
"clap://class/web/restlet_docs/schema/");





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=2681316

Reply via email to