Lukasz,

It was a few months ago, but I recall encountering the same problem when trying to define a Guice module. As you described, it worked fine without a Module but failed when one was specified. I tracked it down to a bug (in the plugin I think?) and it was solved by building the current version of Guice from source.

Building it was extremely easy.
I currently use revision 328 from http://google-guice.googlecode.com/svn/trunk (which is many months old)

My configuration is as Oleg described, with the addition of the module specification in struts.xml

Extract from struts.xml
<constant name="guice.module" value="packagename.ExampleModule"/>

Extract from struts.properties:
struts.objectFactory = guice

ie. No need to use the Guice filter in web.xml.

hope that helps,
Jeromy Evans

Łukasz Łapiński wrote:
On Fri, 27 Jul 2007 13:13:15 +0200, Oleg Mikheev <[EMAIL PROTECTED]> wrote:

Łukasz Łapiński wrote:
I would really love to use IoC in my struts project. Has anyone any experiences with integration Struts and Guice.

I'm using Guice, but I'm not defining any modules
(what do you need them for?)
I just added 3 libs (guice-1.0.jar, guice-servlet-1.0.jar,
guice-struts2-plugin-1.0.1.jar) to WEB-INF/lib,
and put this line to struts.xml:
<constant name="struts.objectFactory" value="guice" />

That's all I had to do to be able to use @Inject in actions.

Oleg

Hi Oleg,

thx for the answer. How do you inject into your web applications JNDI resources, such as data sources if you dont use any modules ?
I think this is where one could use

// Bind to DataSource from JNDI.
bind(DataSource.class)
  .toProvider(fromJndi(DataSource.class, "..."));

which comes from Guice user guide.





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to