Get rid of init() altogether and just constructor inject your servlets.
Remove them from web.xml and move them to ServletModule:
new ServletModule() {
serve("/myservet").with(MyServlet.class);
}
class MyServlet {
@Inject MyServlet(Dep1 dep...) {
// etc.
}
Your web.xml should be empty except for the code snippet for GuiceFilter
(from the wiki tute you linked to).
Dhanji.
On Thu, Mar 5, 2009 at 9:41 AM, Leigh Klotz <[email protected]> wrote:
>
> I've been using an earlier snapshot and am upgrading to Guice 2
> prerelease snapshot 20090205.
>
> I've been relying on injection into servlets happening in the init
> (ServletConfig) method once super.init(servletConfig) has been
> called. I did not previously use the GuiceFilter in web.xml, as I did
> not use Request or Session annotations.
>
> I noticed that com.google.inject.servlet.InjectedHttpServlet went away
> and so I removed it, and put in th GuiceFilter and applied it to "/*",
> as described in http://code.google.com/p/google-guice/wiki/Servlets
>
> However, I'm finding that the servlets are not being injected during
> init. I'm not surprised, since I don't see how the servlet instances
> can be found through a filter in web.xml during init, and there's no
> Guice code in the init() hierarchy any more.
>
> What's the recommended path for me to make use of Guice in servlets
> during their init?
>
> Leigh.
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---