Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

rest

restlet

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?

like image 699
jaxb Avatar asked Oct 14 '22 00:10

jaxb


1 Answers

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.

like image 106
Avi Flax Avatar answered Nov 15 '22 09:11

Avi Flax