Why does Restlet on GAE says Component is NULL
Asked Answered
S

1

8

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 ?

Schizoid answered 22/6, 2016 at 18:59 Comment(0)
R
0

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.

Runkle answered 9/9, 2016 at 9:43 Comment(1)
yes I did. I followed it by the book. Funny part is I am running it without issues, but these logs freak me outSchizoid

© 2022 - 2024 — McMap. All rights reserved.