Google GUICE is a great lightweight dependency injection framework that comes with a plugin for struts2. Using guice 2.0 and
struts2.1.6 on tomcat6 I run into a dependency problem with different xwork and ognl jars provided by struts and the struts2 plugin from guice:
[INFO] +- org.apache.struts:struts2-core:jar:2.1.6:compile
[INFO] | +- com.opensymphony:xwork:jar:2.1.2:compile
[INFO] | | \- org.springframework:spring-test:jar:2.5.6:test (scope managed from compile)
[INFO] | +- opensymphony:ognl:jar:2.6.11:compile
[INFO] | \- commons-fileupload:commons-fileupload:jar:1.2.1:compile
...
[INFO] +- com.google.inject.extensions:guice-struts2-plugin:jar:2.0:compile
[INFO] | \- opensymphony:xwork:jar:2.0.0:compile
[INFO] | \- ognl:ognl:jar:2.6.9:compile
This can easily be resolved excluding the older OGNL library from guice like this in your POM:
<dependency>
<groupid>com.google.inject.extensions</groupid>
<artifactid>guice-struts2-plugin</artifactid>
<version>2.0</version>
<exclusions>
<exclusion>
<groupid>opensymphony</groupid>
<artifactid>xwork</artifactid>
</exclusion>
<exclusion>
<groupid>ognl</groupid>
<artifactid>ognl</artifactid>
</exclusion>
</exclusions>
</dependency>