How to use Google Guice with Richfaces 4.3.7

天大地大妈咪最大 提交于 2020-01-25 05:28:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!