This discussion is archived
0 Replies Latest reply: Oct 3, 2012 6:12 AM by 965904 RSS

Restlets not responding even though request shows in console

965904 Newbie
Currently Being Moderated
Restlet Code

public static void main(String[] args) {

Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
component.getClients().add(Protocol.FILE);


Context ctx = component.getContext();
final Context childCtx = ctx.createChildContext();
Application application = new Application(childCtx) {
@Override
public Restlet createRoot() {
// Create a root router
Router router = new Router(childCtx);

public void handle(Request request, Response response) {
// Print the user name of the requested orders
String message = "Orders of user \""
+ request.getAttributes().get("users") + "\"";
response.setEntity(message, MediaType.TEXT_PLAIN);
}
};

router.attach("/users/{user}", account);
router.attach("/object/", TestServerResource.class);

return router;
}

component.getDefaultHost().attach(application);

component.start();
}
}
}

When I use the GUI test tool and submit a GET request the console logs the fact that a request was received but no data is returned. A breakpoint in the handle() method is never hit. The TestServerResource class is never accessed either. I copied this example from the Restlet user guide. I feel like I have entered everything correctly but things just aren't working. Is there an important step that I have missed?


Here's some more information

I am using WizTools.org RESTClient 3.0

I issue the following GET request

127.0.0.1:8182/users/1 through RESTClient 3.0

The java console shows

Oct 03, 2012 8:40:02 AM com.noelios.restlet.LogFilter afterHandle
INFO: 2012-10-03     08:40:02     127.0.0.1     -     -     8182     GET     /users/1     -     200     0     -     16     http://127.0.0.1:8182     Apache-HttpClient/4.2.1 (java 1.5)     

The RESTClient output shows

Oct 03, 2012 8:40:03 AM org.wiztools.restclient.HTTPClientRequestExecuter execut
e
WARNING: Content-Type header not available in response. Using platform default e
ncoding: windows-1252

The RESTClient 3.0 GUI reports

Content-Length 0
Date: (a date value of the request)
Accept-Ranges bytes
Server Noelios-Restlet-Engine/1.1.10
Connection close

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points