By default, GuiceFilter is registered for both application and admin contexts:


Actually, the same GuiceFilter instance is used for both contexts. This way request scope works properly on both contexts, and registrations through ServeletModule are available both context. See web mappings report.

Example of servlet and filter registration through guice module:

public class WebModule extends ServletModule {

    protected void configureServlets() {

    .modules(new WebModule())


Rest context is mapped to root by default. To change it use configuration file:

    rootPath: '/rest/*'


With guice you can map servlets and filters using regexps


It may be more handy to use web extensions instead of direct registrations. For example, it is the only way to bind servlets in admin context.


By default, GuiceFilter is registered with REQUEST dispatcher type. If you need to use other types use option:

    .option(GuiceyOptions.GuiceFilterRegistration, EnumSet.of(REQUEST, FORWARD))


Note that async servlets and filters can't be used with guice servlet module (and so it is impossible to register GuiceFilter for ASYNC type). Use web installers for such cases.


GuiceFilter dispatch all requests for filters and servlets registered by ServletModule internally and there may be problems combining servlets from ServletModule and filters in main scope.

Disable ServletModule support


Option is deprecated because request scope will become mandatory for the next guicey version (due to HK2 remove).

If you don't use servlet modules (for example, because web installers cover all needs) you can disable guice servlet modules support:


It will:

  • Avoid registration of GuiceFilter in both contexts
  • Remove request and session guice scopes support (because no ServletModule registered)
  • Prevent installation of any ServletModule (error will be thrown indicating duplicate binding)
  • HttpServletRequest and HttpServletResponse still may be injected in resources with Provider (but it will not be possible to use such injections in servlets, filters or any other place)

Disabling saves about ~50ms of startup time.