I'm using restlet in a proof-of-concept as follows:
final Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
final Router router = new Router(component.getContext().createChildContext());
router.attachDefault(HttpListener.class);
component.start();
This should give me a URL path of http://localhost:8182/*
. However, I just get 404 errors when trying to GET from this URL:
http://localhost:8182/ -> 404
http://localhost:8182/xyz -> 404
Restlet isn't routing any requests to my HttpListener class.
My HttpListener class:
public class HttpListener extends ServerResource {
public static void main(String[] args) throws Exception {
final Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
final Router router = new Router(component.getContext().createChildContext());
router.attachDefault(HttpListener.class);
component.start();
}
@Get()
public Representation getDBName() {
String body = "hello, world";
Representation representation = new StringRepresentation(body, MediaType.APPLICATION_JSON);
representation.setCharacterSet(CharacterSet.UTF_8);
return representation;
}
}