Android-Restlet 2.2服务器首次运行-没有可用的服务器连接器 [英] Android - First run of Restlet 2.2 server - No available server connector
问题描述
我正在尝试使用以下代码运行我的第一台Restlet服务器:
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.
我将"org.restlet.jar"复制到\ libs文件夹,并将JAR添加到Java Build Path中的库中.我该怎么办?怎么了?
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?
推荐答案
如果将其配置为使用NIO HttpServerHelper,则可以运行它.只需下载NIO扩展并在RestLet Engine中对其进行配置,您就可以再次启动HTTP服务器. (在2.3.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));
要查看您的版本是否可以使用NIO扩展,可以看一下: http://restlet.com/technical-resources/restlet -framework/guide/2.3/extensions/editions-matrix
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
这篇关于Android-Restlet 2.2服务器首次运行-没有可用的服务器连接器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!