Tuesday, September 13, 2016

Why does Restlet on GAE says Component is NULL

Leave a Comment

On every request made to the Restlet resources, I see the following logs in Google App Engine Logs

21:38:50.059 javax.servlet.ServletContext log: ExampleAPIs: [Restlet] ServerServlet: component class is null 21:38:51.568 javax.servlet.ServletContext log: ExampleAPIs: [Restlet] Attaching application: com.example.api.ExampleAPIConfig@68ec99 to URI: /example/v1 

Why does it say Component is null? I agree that I did not define Components rather used ServerResources and mapped them to the router in the Application class. But thats how it is supposed to be done as per the Restlet GAE Edition documentation.

Application class for wiring routes

public Example extends Application {     @Override     public Restlet createInboundRoot() {         router = new Router(getContext());         CorsService corsService = new CorsService();                  corsService.setAllowedOrigins( new HashSet<String>(Arrays.asList("http://example.com")));         corsService.setAllowedCredentials(true);         getServices().add(corsService);           router.attach("/xyz", XYZ.class);     } } 

Server Resource which handles and returns a JSON Representation

public class XYZ extends ServerResource {      private static final Logger logger = Logger.getLogger("API:Xyz");      @Get(":json")     public Representation handleGetRequest() {          ..          return new JsonRepresentation("{\"code\": 4008, \"description\": \"Something blah something\"}");     } } 

Is there something I am doing wrong ?

1 Answers

Answers 1

Did you configure your servlet configuration file as explained in document (below link). I think servlet is not bound to a class.

https://restlet.com/technical-resources/restlet-framework/guide/2.3/editions/gae

Update

Ok so if you deeper in documentation : https://restlet.com/technical-resources/restlet-framework/javadocs/2.0/jee/ext/org/restlet/ext/servlet/ServerServlet.html
https://restlet.com/technical-resources/restlet-framework/javadocs/2.0/jee/api/org/restlet/Component.html You can see that component is optional but can be usefull, but maybe in GAE implementation it doesn't have one by default.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment