问题
I'm programming a web app which uses richfaces 4.3.7 and google guice 4.0.
The problem is that richfaces using guava 18 und google guice using guava 16, this results with the following Exception:
java.lang.RuntimeException: java.lang.IllegalAccessError: tried to access method com.google.common.collect.MapMaker.makeComputingMap(Lcom/google/common/base/Function;)Ljava/util/concurrent/ConcurrentMap; from class org.richfaces.resource.ResourceLibraryFactoryImpl
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalAccessError: tried to access method com.google.common.collect.MapMaker.makeComputingMap(Lcom/google/common/base/Function;)Ljava/util/concurrent/ConcurrentMap; from class org.richfaces.resource.ResourceLibraryFactoryImpl
Does anyone know a solution? I'm using gradle for dependency management.
Update:
dependencies {
compile 'com.sun.faces:jsf-api:2.2.9'
compile 'com.sun.faces:jsf-impl:2.2.9'
compile 'jstl:jstl:1.2'
compile 'org.hibernate:hibernate-core:4.3.6.Final'
compile 'mysql:mysql-connector-java:5.1.31'
compile 'com.google.inject:guice:4.0'
compile 'org.richfaces.core:richfaces-core-api:4.3.7.Final'
compile 'org.richfaces.core:richfaces-core-impl:4.3.7.Final'
compile 'org.richfaces.ui:richfaces-components-api:4.3.7.Final'
compile 'org.richfaces.ui:richfaces-components-ui:4.3.7.Final'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
回答1:
Try to exclude Guice subdependency, so it will use Richfaces Guava version.
compile 'com.google.inject:guice:4.0' {
exclude group: 'com.google.guava', module: 'guava'
}
来源:https://stackoverflow.com/questions/32319981/how-to-use-google-guice-with-richfaces-4-3-7