I've been using Guice 1.0 with Struts 2.1.6 and the struts plugin.
I just replaced the Guice 1.0 jars with the Guice 2.0 jars:

guice-2.0.jar
guice-struts2-plugin-2.0.jar
guice-servlet-2.0.jar

When I try to start my application (in Tomcat from Eclipse) I get:

2009-05-20 13:14:41,667 INFO
com.opensymphony.xwork2.config.providers.XmlConfigurationProvider:31 -
Parsing configuration file [struts-default.xml]
2009-05-20 13:14:41,866 INFO
com.opensymphony.xwork2.config.providers.XmlConfigurationProvider:31 -
Parsing configuration file [struts-plugin.xml]
2009-05-20 13:14:41,873 ERROR org.apache.catalina.core.ContainerBase.
[Catalina].[localhost].[/nxm]:3639 - Exception starting filter struts2
Unable to load configuration. - bean - jar:file:/C:/Eclipse/
workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/
wtpwebapps/Allman%20Resolution%20v1/WEB-INF/lib/guice-struts2-
plugin-2.0.jar!/struts-plugin.xml:11:63
        at
com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration
(ConfigurationManager.java:58)
        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration
(Dispatcher.java:360)
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:403)
        at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher
(InitOperations.java:69)
        at
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init
(StrutsPrepareAndExecuteFilter.java:48)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter
(ApplicationFilterConfig.java:221)
        at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef
(ApplicationFilterConfig.java:302)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>
(ApplicationFilterConfig.java:78)
        at org.apache.catalina.core.StandardContext.filterStart
(StandardContext.java:3635)
        at org.apache.catalina.core.StandardContext.start
(StandardContext.java:4222)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:
1014)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:
1014)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:
443)
        at org.apache.catalina.core.StandardService.start
(StandardService.java:448)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:
700)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: Unable to load bean:
type:com.opensymphony.xwork2.ObjectFactory
class:com.google.inject.struts2.GuiceObjectFactory - bean - jar:file:/
C:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/
tmp1/wtpwebapps/Allman%20Resolution%20v1/WEB-INF/lib/guice-struts2-
plugin-2.0.jar!/struts-plugin.xml:11:63
        at
com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register
(XmlConfigurationProvider.java:222)
        at org.apache.struts2.config.StrutsXmlConfigurationProvider.register
(StrutsXmlConfigurationProvider.java:101)
        at
com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer
(DefaultConfiguration.java:165)
        at
com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration
(ConfigurationManager.java:55)
        ... 22 more
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with
the name guice has already been loaded by bean - jar:file:/C:/Eclipse/
workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/
wtpwebapps/Allman%20Resolution%20v1/WEB-INF/lib/guice-struts2-
plugin-1.0.1.jar!/struts-plugin.xml:11:63 - bean - jar:file:/C:/
Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/
wtpwebapps/Allman%20Resolution%20v1/WEB-INF/lib/guice-struts2-
plugin-2.0.jar!/struts-plugin.xml:11:63
        at
com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register
(XmlConfigurationProvider.java:206)
        ... 25 more
May 20, 2009 1:14:45 PM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
May 20, 2009 1:14:45 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/nxm] startup failed due to previous errors

Any ideas?

I haven't changed anything except swap the 3 jar files.

My struts.xml has:
        <constant name="struts.objectFactory" value="guice" />
        <constant name="guice.module"
                value="com.nexmobile.server.inject.MainModule" />

More info:  When I run my full set of unit tests I get many of these
warnings:

May 20, 2009 1:31:06 PM com.google.inject.servlet.GuiceFilter
setPipeline
WARNING: Multiple injectors detected. Please install only one
ServletModule in your web application. While you may have more than
one injector, you should only configure guice-servlet in one of them.
(Hint: look for legacy ServetModules or multiple calls to
Servlets.configure()).

However if I run my tests one at a time I don't get the warnings.  Is
there a cleanup step that is needed after a test is run to prevent
Guice state from bleeding over between tests?

Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to