If you have the following code to create a Restlet instance:

   new Restlet() {
         public void handle(Request request,Response response)
         {
            getContext().getLogger().info("Handling test...");
            response.setStatus(Status.SUCCESS_OK,"OK!");
         }
      };

you'll get a null pointer exception because getClass().getCanonicalName()
returns null.

I've tracked it down to line 75 of Restlet.java in the getContext() method:

    public Context getContext() {
        if (this.context == null)
            this.context = new Context(getClass().getCanonicalName());
        return this.context;
    }


There needs to be a default log name:

    public Context getContext() {
        if (this.context == null) {
           String logName = getClass().getCanonicalName();
            if (logName==null) {
                logName = "org.restlet.anonymous";
            }
            this.context = new Context(logName);
        }
        return this.context;
    }


--Alex Milowski

Reply via email to