Android - first launch of Restlet 2.2 server - no server connector available

I am trying to start my first Restlet server using this code:

import org.restlet.Server;
import org.restlet.data.Protocol;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

public class WebServer extends ServerResource {

    /**
     * @param args
     * @throws Exception
     */
    public WebServer() throws Exception {
        // Create the HTTP server and listen on port 8182
        Server server = new Server(Protocol.HTTP, 8182, WebServer.class);
        server.start();

    }

    @Get
    public String present() {
        return "hello, world";
    }
}

      

But when I start the server I get this error message:

No available server connector supports the required protocols: 'HTTP' . Please add the JAR of a matching connector to your classpath. Then, register this connector helper manually.

I copied "org.restlet.jar" to the \ libs folder and added the JARs to the libraries in the Java build path. What should I do? What's wrong?

+3


source to share


1 answer


you can run it if you configure it to use the NIO HttpServerHelper. Simply downloading NIO and configuring it in RestLet Engine will allow you to start your HTTP server again. (Tested on 2.3.1).

import org.restlet.ext.nio.HttpServerHelper; 

...

Engine.getInstance().getRegisteredServers().clear();
Engine.getInstance().getRegisteredServers().add(new HttpServerHelper(null));

      



To see if the NIO extension is available for your version, you can look at: http://restlet.com/technical-resources/restlet-framework/guide/2.3/extensions/editions-matrix

+3


source







All Articles