No available client connector supports the required protocol: 'HTTP'

只谈情不闲聊 提交于 2019-12-10 15:36:27

问题


Greeting. I am playing with Restlet framework, when I am running following code getting and exception Internal Connector Error (1002) - No available client connector supports the required protocol: 'HTTP'.

ClientResource cr = new ClientResource(
"http://127.0.0.1:8888/user/123");
UserResource resource = cr.wrap(UserResource.class);
User user = new User();
user.setName("xxx");
user.setPassword("xxx");
UserValidation userValidation = resource.retrieve(user);
if (userValidation != null) {
  System.out.println("Welcome, User");
} else {
  System.out.println("Not a vliad user");
}

Is there anybody here tried the Retlet before? Can guide me to proper direction? Or can redirect to helpfull tutorial?


回答1:


Restlet depends on "connectors" to implement clients and servers. They're kind of like plugins, in that they're modular, and you can easily choose which to use. At runtime, Restlet checks the classpath to see which connectors are available, and loads them. Each connector is packaged in 1 JAR file for the connector itself plus N files for dependencies. So you can make a connector available to the framework by simply adding the relevant JARs to the classpath.

You must be using Restlet 1.0 or 1.1, because 2.0 includes simple built-in HTTP client and server connectors. I suggest you upgrade to 2.0; it's a lot easier to develop with because a single JAR contains the framework, engine, and the built-in connectors; with 1.1 you can sometimes need 6-7 JARs just to test a simple app.



来源:https://stackoverflow.com/questions/3684452/no-available-client-connector-supports-the-required-protocol-http

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!