Child pages
  • Guice Plugin
Skip to end of metadata
Go to start of metadata


Guice Plugin


Apache Software Foundation


Open Source (ASL2)





Source Code

Guice User Guide's%20Guide.pdf



The Guice plugin INLINE

allows Actions, Interceptors, and Results to be injected by Guice



  • Struts 2.0.6+

Installation and Usage

To install the Guice Struts 2 plugin with Struts 2.0.6 or later, simply include guice-struts2-plugin-1.0.jar in your web application's classpath and select Guice as your ObjectFactory implementation in your struts.xml file:

<constant name="struts.objectFactory" value="guice" />

Guice will inject all of your Struts 2 objects including actions and interceptors. You can even scope your actions. You can optionally specify a Module for Guice to install in your struts.xml file:

<constant name="guice.module" value="mypackage.MyModule"/>

If all of your bindings are implicit, you can get away without defining a module at all.

  • No labels

1 Comment

  1. Nice plugin and works well once configured properly.

        <constant name="struts.objectFactory" value="guice" />
    to your struts.xml file may not work properly. I had a problem where my application was trying to use the spring object factory.
    I had to change the value struts.objectFactory property in the application file to "guice".

    In addition if you want to use the Guice Servlet scopes you have to add an additional filter to your web.xml file.