Discussion:
Unable to access HttpServletRequest from GroupBackend
Chris Kyrouac
2013-12-19 15:49:55 UTC
Permalink
Hi, I am working on a group backend plugin that requires access to the
original HttpServletRequest object. I tried injecting both
HttpServletRequest and Provider<HttpServletRequest> into the group backend.
Either way I get a message saying, "No implementation for
javax.servlet.http.HttpServletRequest was bound.", in error_log when Gerrit
tries to load the plugin. I'm under the impression that guice-servlet
should have bound an implementation of HttpServletRequest. I see that
gerrit doesn't have the guiceFilter set in web.xml but I'm not sure if some
trickery is done in WebAppInitializer to create the necessary bindings.

I have also tried injecting CacheBasedWebSession similarly with no success.
When I first try to inject it into my group backend, RequestScoped was not
bound to an implementation. So, I bound it to
PerThreadRequestScope.REQUEST. Now I get four errors when trying to load
the plugin:

1) No implementation for com.google.common.cache.Cache<java.lang.String,
com.google.gerrit.httpd.WebSessionManager$Val> annotated with
@com.google.inject.name.Named(value=web_sessions) was bound

2) No implementation for java.net.SocketAddress annotated with
@com.google.gerrit.server.RemotePeer() was bound.

3) No implementation for javax.servlet.http.HttpServletRequest was bound.

4) No implementation for javax.servlet.http.HttpServletResponse was bound.
This is all with Gerrit 2.8 and v2.8 of plugin-api.jar.

Is there a way to get HttpServletRequest that I'm missing?

Thanks!
Chris
--
--
To unsubscribe, email repo-discuss+***@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Shawn Pearce
2013-12-19 16:06:58 UTC
Permalink
Post by Chris Kyrouac
Hi, I am working on a group backend plugin that requires access to the
original HttpServletRequest object. I tried injecting both
HttpServletRequest and Provider<HttpServletRequest> into the group backend.
Either way I get a message saying, "No implementation for
javax.servlet.http.HttpServletRequest was bound.", in error_log when Gerrit
tries to load the plugin. I'm under the impression that guice-servlet should
have bound an implementation of HttpServletRequest. I see that gerrit
doesn't have the guiceFilter set in web.xml but I'm not sure if some
trickery is done in WebAppInitializer to create the necessary bindings.
I have also tried injecting CacheBasedWebSession similarly with no success.
When I first try to inject it into my group backend, RequestScoped was not
bound to an implementation. So, I bound it to PerThreadRequestScope.REQUEST.
1) No implementation for com.google.common.cache.Cache<java.lang.String,
com.google.gerrit.httpd.WebSessionManager$Val> annotated with
@com.google.inject.name.Named(value=web_sessions) was bound
2) No implementation for java.net.SocketAddress annotated with
@com.google.gerrit.server.RemotePeer() was bound.
3) No implementation for javax.servlet.http.HttpServletRequest was bound.
4) No implementation for javax.servlet.http.HttpServletResponse was bound.
This is all with Gerrit 2.8 and v2.8 of plugin-api.jar.
Is there a way to get HttpServletRequest that I'm missing?
No.

GroupBackends must work in the system injector module, which does not
have access to the HTTP environment. The system injector handles
request-less processing like background activity, and supports both
SSH connections and HTTP requests. Like background activity, SSH
connections do not have an HTTP request.

GroupBackends need to be invoked for a user that is not the current
user. Even under an HTTP request. So you can't rely on data in an
HttpServletRequest to support the GroupBackend.

--
Chris Kyrouac
2013-12-19 16:09:52 UTC
Permalink
Cool. Thanks for the quick reply!

Chris
Post by Chris Kyrouac
Post by Chris Kyrouac
Hi, I am working on a group backend plugin that requires access to the
original HttpServletRequest object. I tried injecting both
HttpServletRequest and Provider<HttpServletRequest> into the group
backend.
Post by Chris Kyrouac
Either way I get a message saying, "No implementation for
javax.servlet.http.HttpServletRequest was bound.", in error_log when
Gerrit
Post by Chris Kyrouac
tries to load the plugin. I'm under the impression that guice-servlet
should
Post by Chris Kyrouac
have bound an implementation of HttpServletRequest. I see that gerrit
doesn't have the guiceFilter set in web.xml but I'm not sure if some
trickery is done in WebAppInitializer to create the necessary bindings.
I have also tried injecting CacheBasedWebSession similarly with no
success.
Post by Chris Kyrouac
When I first try to inject it into my group backend, RequestScoped was
not
Post by Chris Kyrouac
bound to an implementation. So, I bound it to
PerThreadRequestScope.REQUEST.
Post by Chris Kyrouac
1) No implementation for com.google.common.cache.Cache<java.lang.String,
com.google.gerrit.httpd.WebSessionManager$Val> annotated with
@com.google.inject.name.Named(value=web_sessions) was bound
2) No implementation for java.net.SocketAddress annotated with
@com.google.gerrit.server.RemotePeer() was bound.
3) No implementation for javax.servlet.http.HttpServletRequest was
bound.
Post by Chris Kyrouac
4) No implementation for javax.servlet.http.HttpServletResponse was
bound.
Post by Chris Kyrouac
This is all with Gerrit 2.8 and v2.8 of plugin-api.jar.
Is there a way to get HttpServletRequest that I'm missing?
No.
GroupBackends must work in the system injector module, which does not
have access to the HTTP environment. The system injector handles
request-less processing like background activity, and supports both
SSH connections and HTTP requests. Like background activity, SSH
connections do not have an HTTP request.
GroupBackends need to be invoked for a user that is not the current
user. Even under an HTTP request. So you can't rely on data in an
HttpServletRequest to support the GroupBackend.
--
--
To unsubscribe, email repo-discuss+***@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Loading...