Hello,

there is a (not so) small constraint with GAE. GAE does not give you access
to the file system, therefore, the File connector has been removed for this
edition.

I suggest that you remove this instruction:
component.getClients().add(Protocol.FILE);

The following one (at the application level) is declarative, but not only.
It says that the current application requires this connector and will not
start if the latter is ont registered:
getConnectorService().getClientProtocols().add(Protocol.FILE);

The lack of this instruction has one consequence. The application will
start, but the first request using this protocol will fail if there is no
FILE connector registered.

Well, back to your problem.
You can either serve static files from the classpath or the "war" context
since gae app runs inside a servlet container.

// Here is the code when serving wia the War context (assuming your files
are under the war root directory)
@Override
   public Restlet createInboundRoot() {
       Router router = new Router(getContext());
       // Serve the files generated by the GWT compilation step.
      Directory dir = new Directory(getContext(),"war:///");
      router.attachDefault(dir);
      router.attach("/contacts/123", ContactServerResource.class);return
router;
  }
You can notice that there is a "war" protocol, and an associated "war"
connector (just as for the "FILE", "HTTP", "CLAP", etc protocols).
The declaration of this war connector is implicit, it is only shipped with
the "org.restlet.ext.servlet" extension.

// Here is the code when serving wia the Clap context (assuming your files
are under the war root directory)
@Override
   public Restlet createInboundRoot() {
       Router router = new Router(getContext());
       // Serve the files generated by the GWT compilation step.
      Directory dir = new
Directory(getContext(),LocalReference.createClapReference(LocalReference.CLAP_CLASS,
"<path to your files>"));
      router.attachDefault(dir);
      router.attach("/contacts/123", ContactServerResource.class);return
router;
  }

Best regards,
THierry Boileau

Hi all,
>
> I am a beginner to restlet. I am trying to use restlet for my android
> client
> and google app engine server.
>
> I tired executing a program that I got from Restlet webiste but it is
> showing the warning
>
>
> "The protocol used by this request is not declared in the list of client
> connectors. (FILE)" even after adding the following line in the code
>
> component.getClients().add(Protocol.CLAP);
>
> Here is the code for server using google app engine and restlet:
>
> package server.application;
>
> import java.io.File;
>
> import org.restlet.Application;
> import org.restlet.Component;
> import org.restlet.Restlet;
> import org.restlet.data.LocalReference;
> import org.restlet.data.Protocol;
> import org.restlet.resource.Directory;
> import org.restlet.routing.Router;
>
> public class TestServerApplication extends Application {
>
>    /**
>     * When launched as a standalone application.
>     *
>     * @param args
>     * @throws Exception
>     */
>    public static void main(String[] args) throws Exception {
>        Component component = new Component();
>
>        component.getServers().add(Protocol.HTTP, 8080);
>        component.getClients().add(Protocol.CLAP);
>        component.getClients().add(Protocol.FILE);
>
>        component.getDefaultHost().attach(new TestServerApplication());
>        component.start();
>    }
>
>    @Override
>    public Restlet createInboundRoot() {
>        Router router = new Router(getContext());
>        getConnectorService().getClientProtocols().add(Protocol.FILE);
>
>        // Serve the files generated by the GWT compilation step.
>        File warDir = new File("");
>        if (!"war".equals(warDir.getName())) {
>            warDir = new File(warDir, "war/");
>        }
>       // final Directory dir = new Directory(getContext(),
> "clap://class/web/restlet_docs/schema/".createFileReference(warDir)));
>        Directory dir = new Directory(getContext(), LocalReference
>                .createFileReference(warDir));
>        router.attachDefault(dir);
>        router.attach("/contacts/123", ContactServerResource.class);
>
>        return router;
>    }
>
> }
> *****
>
> When I try to run the server it shows
>
> INFO: The server is running at http://localhost:3165/
>
> but when I go to this url and click the link it shows the error message
>
> org.restlet.engine.component.ClientRouter getNext
> WARNING: The protocol used by this request is not declared in the list of
> client connectors. (FILE)
>
>
> Please help me out.
>
> Thanks in advance
>
>
> --
> View this message in context:
> http://restlet-discuss.1400322.n2.nabble.com/The-protocol-used-by-this-request-is-not-declared-in-the-list-of-client-connectors-FILE-tp6006629p6006629.html
> Sent from the Restlet Discuss mailing list archive at Nabble.com.
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2702949
>

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

Reply via email to