"ServletScopes.REQUEST already bound" when ServletModule used with Modules.override or PrivateModule
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
_From [jeffjcrowe](https://code.google.com/u/116966542706070883618/) on July 04, 2011 21:02:01_
When ServletModules are combined with PrivateModule or Modules.override (for test code), Injector creation fails with the binding errors below.
Code to reproduce:
Guice.createInjector(new AbstractModule(){
`@`Override
protected void configure() {
install(new ServletModule ());
install(new PrivateModule() {
`@`Override protected void configure() {
install(new ServletModule ());
}
});
}
});
OR
Guice.createInjector(new AbstractModule(){
`@`Override
protected void configure() {
install(new ServletModule ());
install(Modules.override(new ServletModule ()).with());
}
});
1) Scope ServletScopes.REQUEST is already bound to com.google.inject.servlet.RequestScoped. Cannot bind ServletScopes.REQUEST.
at com.google.inject.servlet.InternalServletModule.configure(InternalServletModule.java:77)
2) Scope ServletScopes.SESSION is already bound to com.google.inject.servlet.SessionScoped. Cannot bind ServletScopes.SESSION.
at com.google.inject.servlet.InternalServletModule.configure(InternalServletModule.java:78)
3) A binding to javax.servlet.ServletRequest was already configured at com.google.inject.servlet.InternalServletModule.configure(InternalServletModule.java:79).
at com.google.inject.servlet.InternalServletModule.configure(InternalServletModule.java:79)
... output snipped ..
_Original issue: http://code.google.com/p/google-guice/issues/detail?id=639_
Contributor guide
Research direction
Start with the reproduced injector configurations in the issue and read com.google.inject.servlet.InternalServletModule.configure, especially the lines reported in the binding errors. Determine why installing ServletModule through PrivateModule or Modules.override repeats the request and session scope bindings. Done means both reproductions create an injector without the duplicate-binding errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100