RESTLET-HELLO WORLD in GWT

972 Views Asked by At

I worked out a simple hello world application using Restlet in GWT, but it throwed out me with

"No available client connector supports the required protocol: 'HTTP'" in client side and in server side

"No available server connector supports the required protocols: 'HTTP' . Please add the JAR of a matching connector to your classpath."

Here is my hello world app:

Client:

import org.restlet.resource.ClientResource;

public class HelloClient {

    public static void main(String[] args) throws Exception {
        ClientResource helloClientresource = new ClientResource(
                "http://localhost:8111/");
        helloClientresource.get().write(System.out);
    }
}

ServerResource:

import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

/**
 * Simple "hello, world" server resource.
 */
public class HelloServerResource extends ServerResource {

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

Server:

import org.restlet.Server;
import org.restlet.data.Protocol;
public class HelloServer {

    public static void main(String[] args) throws Exception {
        Server helloServer = new Server(Protocol.HTTP, 8111,
                HelloServerResource.class);
        helloServer.start();
    }

}
1

There are 1 best solutions below

1
Jama A. On

"No available server connector supports the required protocols: 'HTTP' . Please add the JAR of a matching connector to your classpath"

Make sure you have added relevant jar file into your classpath: For example:The GWT client relies only on the core Restlet JAR (org.restlet.jar) provided in the GWT edition. And also see FAQ: What JAR files must I have in my classpath for a minimal application? and also see the answer given here: No available client connector supports the required protocol: 'HTTP'