Extension REST endpoint not working

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Extension REST endpoint not working

Ben Davis
I'm attempting to add a REST endpoint to my extension. As a starting point, I wanted to see if I could get a simple GET request working, but I'm running into trouble.

I copied the quickconnect extension as reference point. My UserContext class implements the getResource() method:

     @Override
     public Object getResource() throws GuacamoleException {
         return new WorkspaceREST(this.connectionDirectory);
     }

The REST class looks like this:

@Produces(MediaType.APPLICATION_JSON)
public class WorkspaceREST {
    private final WorkspaceDirectory directory;
    
    public WorkspaceREST(WorkspaceDirectory directory) {
        this.directory = directory;
    }
    
    @GET
    @Path("test")
    public Map<String, String> test() {
       logger.info("REST test");
       return Collections.singletonMap("success", "true");
    }
}

My authenticationProvider's identifier is "boldidea-workspaces", so I tried the following url (after logging in and inspecting my token):

/guacamole/api/session/ext/boldidea-workspaces/test?token=XXXXX

I get a 500 response, with the tomcat logs showing the following error:

com.sun.jersey.api.NotFoundException: null for uri: http://localhost:8080/guacamole/api/session/ext/boldidea-workspaces/test/?token=XXXXX

What's the best way to troubleshoot this? 

Ben Davis
Education Director

214-442-1635  | https://boldidea.org/



Reply | Threaded
Open this post in threaded view
|

Re: Extension REST endpoint not working

vnick


On Sat, Dec 7, 2019 at 10:12 PM Ben Davis <[hidden email]> wrote:
I'm attempting to add a REST endpoint to my extension. As a starting point, I wanted to see if I could get a simple GET request working, but I'm running into trouble.

I copied the quickconnect extension as reference point. My UserContext class implements the getResource() method:

     @Override
     public Object getResource() throws GuacamoleException {
         return new WorkspaceREST(this.connectionDirectory);
     }

The REST class looks like this:

@Produces(MediaType.APPLICATION_JSON)
public class WorkspaceREST {
    private final WorkspaceDirectory directory;
    
    public WorkspaceREST(WorkspaceDirectory directory) {
        this.directory = directory;
    }
    
    @GET
    @Path("test")
    public Map<String, String> test() {
       logger.info("REST test");
       return Collections.singletonMap("success", "true");
    }
}

My authenticationProvider's identifier is "boldidea-workspaces", so I tried the following url (after logging in and inspecting my token):

/guacamole/api/session/ext/boldidea-workspaces/test?token=XXXXX

I get a 500 response, with the tomcat logs showing the following error:

com.sun.jersey.api.NotFoundException: null for uri: http://localhost:8080/guacamole/api/session/ext/boldidea-workspaces/test/?token=XXXXX


It seems like I've run into this before, but cannot remember what the cause was.  A couple of suggestions, though:
- Make sure that you're running the same Guacamole Client version as the extension.  So, if you've checked out the git code and are using that to build the extension, but are installing Guacamole 1.0.0 from the web site, you may run into issues.  Or, if your pom.xml for your extension is pulling the 1.0.0 Guacamole dependencies, but you're deploying a later version of Guacamole client built from git, that may cause issues.
- Enable debugging in the web application, as described here: http://guacamole.apache.org/doc/gug/configuring-guacamole.html#webapp-logging.  Then watch the logs, again, then next time you try to hit that REST endpoint and see what comes up.

-Nick
Reply | Threaded
Open this post in threaded view
|

Re: Extension REST endpoint not working

Ben Davis
My guacamole-client was built from 1.0.0 sources, and my pom.xml pulls 1.0.0 as a dependency, so I don't think that's the issue. I've also already enabled debug logging, and it doesn't give any insight. The guacamole client is returning a 404 response.

How does guacamole client build routes based on the extension? According to my logging in my extension, it is instantiating my WorkspaceREST class, but it does not seem to register the REST path with the client, as the client returns a 404 response.   

Ben Davis
Education Director

214-442-1635  | https://boldidea.org/





On Mon, Dec 9, 2019 at 4:24 PM Nick Couchman <[hidden email]> wrote:


On Sat, Dec 7, 2019 at 10:12 PM Ben Davis <[hidden email]> wrote:
I'm attempting to add a REST endpoint to my extension. As a starting point, I wanted to see if I could get a simple GET request working, but I'm running into trouble.

I copied the quickconnect extension as reference point. My UserContext class implements the getResource() method:

     @Override
     public Object getResource() throws GuacamoleException {
         return new WorkspaceREST(this.connectionDirectory);
     }

The REST class looks like this:

@Produces(MediaType.APPLICATION_JSON)
public class WorkspaceREST {
    private final WorkspaceDirectory directory;
    
    public WorkspaceREST(WorkspaceDirectory directory) {
        this.directory = directory;
    }
    
    @GET
    @Path("test")
    public Map<String, String> test() {
       logger.info("REST test");
       return Collections.singletonMap("success", "true");
    }
}

My authenticationProvider's identifier is "boldidea-workspaces", so I tried the following url (after logging in and inspecting my token):

/guacamole/api/session/ext/boldidea-workspaces/test?token=XXXXX

I get a 500 response, with the tomcat logs showing the following error:

com.sun.jersey.api.NotFoundException: null for uri: http://localhost:8080/guacamole/api/session/ext/boldidea-workspaces/test/?token=XXXXX


It seems like I've run into this before, but cannot remember what the cause was.  A couple of suggestions, though:
- Make sure that you're running the same Guacamole Client version as the extension.  So, if you've checked out the git code and are using that to build the extension, but are installing Guacamole 1.0.0 from the web site, you may run into issues.  Or, if your pom.xml for your extension is pulling the 1.0.0 Guacamole dependencies, but you're deploying a later version of Guacamole client built from git, that may cause issues.
- Enable debugging in the web application, as described here: http://guacamole.apache.org/doc/gug/configuring-guacamole.html#webapp-logging.  Then watch the logs, again, then next time you try to hit that REST endpoint and see what comes up.

-Nick