Adding: binder.bind(PersistenceFilter.class).in(Scopes.SINGLETON);
in a separate Module helped. If this is what developers are supposed to be doing it wasn't immediately obvious to me. If you wish to keep the API as-is I would suggest mentioning in the documentation that Servlet/Filter scopes are supposed to be bound in a separate Module. Gili On Feb 7, 12:40 am, Gili <[email protected]> wrote: > Hi, > > I tried using com.wideplay.warp.persist.PersistenceFilter with guice- > servlet and got this error: > > javax.servlet.ServletException: Filters must be bound as singletons. > Key[type=com.wideplay.warp.persist.PersistenceFilter, annotation= > [none]] was not bound in singleton scope. > > Fair enough, but there is no way for me to do this. Shouldn't > ServletModule.filter() allow me to specify a scope? I don't think it's > realistic to assume that I can modify existing Filters because as this > example shows sometimes I am trying to use 3rd-party code which I > cannot modify. > > Either guice-servlet needs to automatically bind all servlets and > filters to a singleton scope (which is my personal preference) or it > needs to allow me to specify a scope on a Module level without having > to modify the existing Servlet/Filter class. > > Gili --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
