Open GoogleCodeExporter opened 9 years ago
Workaround:
<!--
http://code.google.com/p/google-guice/issues/detail?id=576
Had to manually put the jar (http://repo1.maven.org/maven2/com/google/inject/extensions/guice-struts2-plugin/2.0/) in WEB-INF/lib and explicitly add guice-servlet
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-struts2-plugin</artifactId>
<version>2.0</version>
</dependency>
-->
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
<version>2.0</version>
</dependency>
Original comment by bmcc...@google.com
on 30 Nov 2010 at 7:44
The struts2 extension in Guice2 was dead-on-arrival last I heard. We've
discontinued it for guice3 (see r1423). Although if you're able to rework the
Struts2Factory, add some tests, and keep it entirely in the
com.google.inject.struts2 package (instead of sharing the
com.google.inject.servlet package), we could consider re-adding it.
Original comment by sberlin
on 30 Nov 2010 at 1:42
Another workaround would be to exclude the bad dependency when you depend on
the guice-struts2-plugin:
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-struts2-plugin</artifactId>
<version>2.0</version>
<excludes>
<exclude>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
</exclude>
</excludes>
</dependency>
Unfortunately the 2.0 version of guice-struts2-plugin can't be redeployed
because releases aren't meant to be changed - otherwise different people could
end up with different editions depending when they last sync'd up.
Original comment by mccu...@gmail.com
on 30 Nov 2010 at 1:51
sorry, that should read:
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-struts2-plugin</artifactId>
<version>2.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
</exclusion>
</exclusions>
</dependency>
Original comment by mccu...@gmail.com
on 30 Nov 2010 at 8:24
Cool! Didn't know you could do that. I like that workaround much better.
Note that you should exclude xwork as well:
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-struts2-plugin</artifactId>
<version>2.0</version>
<!-- http://code.google.com/p/google-guice/issues/detail?id=576 -->
<exclusions>
<exclusion>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
</exclusion>
<exclusion>
<groupId>opensymphony</groupId>
<artifactId>xwork</artifactId>
</exclusion>
</exclusions>
</dependency>
You're right that just updating the 2.0 version probably isn't the best idea.
A better idea would be to possibly create a 2.0.1 release with a fix.
Original comment by bmcc...@google.com
on 1 Dec 2010 at 3:14
I really don't want to see the Struts 2 extension disappear with Guice 3, so I
can make it work with Guice 3. What needs to change to add Guice 3 support?
Or are you just deleting it because there's no test?
I don't see anything called Struts2Factory. Do you mean:
http://code.google.com/p/google-guice/source/browse/tags/2.0/struts2/plugin/src/
com/google/inject/struts2/GuiceObjectFactory.java
Original comment by bmcc...@google.com
on 1 Dec 2010 at 3:21
That's the main problem with the extension in Guice 3 -- Struts2Factory is in
the wrong place. It was in the com.google.inject.servlet package, despite
being in the struts2 extension instead of the servlet extension, because the
implementation needed access to package-private things in the servlet module.
It makes it a pain for discoverability, documentation & package-management.
See
http://code.google.com/p/google-guice/source/browse/tags/snapshot20101120/extens
ions/struts2/src/com/google/inject/servlet/Struts2Factory.java for the last
snapshot that contained it.
The fix would ideally be to
a) Move Struts2Factory into the struts2 package and fix its internals so that it doesn't require the servlet package-private things. Basically this means that Struts2Factory has to somehow be given the proper Injector -- very likely by injecting it. Unfortunately I'm not familiar enough with struts2 to know how to fix it to do that, and there's absolutely no tests to validate that it works or will continue to work.
b) Write some tests to verify that it will continue working.
Original comment by sberlin
on 1 Dec 2010 at 3:32
So one thing I noticed is that the example app is broken because the jsp page
got deleted. I'm not sure how to tell via the web SVN view when or why the
file got deleted, but it looks like it needs to be restored. I found it in an
earlier snapshot:
http://code.google.com/p/google-guice/source/browse/tags/snapshot20080611/struts
2/example/root/WEB-INF/Counter.jsp
Original comment by bmcc...@google.com
on 1 Dec 2010 at 5:11
Original comment by sberlin
on 6 Feb 2011 at 5:52
Original issue reported on code.google.com by
bmcc...@google.com
on 30 Nov 2010 at 4:41