问题
I´m trying to run my first Restlet server with 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 the "org.restlet.jar" to the \libs folder and add JAR to the Libraries in Java Build Path. What should I do? What is wrong?
回答1:
it's possible to run it if you configure it to use the NIO HttpServerHelper. Simply downloading the NIO extension and configuring it in the RestLet Engine will allow you to spin up an 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 edition you can have a look on: http://restlet.com/technical-resources/restlet-framework/guide/2.3/extensions/editions-matrix
来源:https://stackoverflow.com/questions/25483312/android-first-run-of-restlet-2-2-server-no-available-server-connector