On Mon, May 28, 2018 at 12:00 PM, Nick Couchman <vn...@apache.org> wrote:

> Hey, everyone,
> I could use some help figuring out how to work this one out.  GUACAMOLE-566
> deals with adding the RESTExceptionWrapper to loaded extensions such that
> the extension-specific REST endpoints will deliver similar Guacamole error
> messages rather than just causing a generic Tomcat Error 500.  Basically
> this means adding an interceptor to the classes such that any of those
> REST-specific methods get passed through the exception wrapper.  I've tried
> a couple of different routes and am not having much success.  The first one
> I tried was this:
>
> https://github.com/necouchman/guacamole-client/blob/
> 22e8fe2b7638a7ab53e957af234c67b5cadc116e/guacamole/src/main/
> java/org/apache/guacamole/extension/Extension.java#L393-L409
>
> Basically I tried creating an injector, using AbstractModule, and binding
> the Interceptor to the class and getting that instance of the class.  This
> didn't work at all - the extensions wouldn't even load and there were
> several errors in the Tomcat localhost log file.  Then, I went this route:
>
> https://github.com/necouchman/guacamole-client/blob/
> 5f3d82a542d2abab4844314d1df83c1262f89083/guacamole/src/main/
> java/org/apache/guacamole/extension/Extension.java#L583-L589
>
> Making the Extension class extend the AbstractModule class and overriding
> configure, and adding the interception, there.  And, while this continues
> to allow the classes to load, it doesn't actually seem to be intercepting
> any of the REST calls - I still just get the same generic Tomcat Error 500
> without the interception.
>
> Any pointers on where to go from here - what needs to be intercepted, and
> where?
>
>
I think we may need to look into a non-Guice mechanism for this to apply to
Guacamole extensions. Reading up on Guice's method interceptors further,
they depend entirely on the intercepted methods being on classes that are
instantiated by Guice injectors. This won't work unless the REST resources
within extensions are instantiated by Guice (probably not a requirement we
want to add onto the extension API):

https://github.com/google/guice/wiki/AOP#limitations

There may be another way, however. Jersey provides for mapping exceptions
to responses:

https://stackoverflow.com/questions/15185299/jax-rs-jersey-exceptionmappers-user-defined-exception

Perhaps we could define such a mapping for GuacamoleException?

- Mike

Reply via email to