weblogic下部署(含JedisResourcePool类引入java.lang.NoSuchMethodError:Equivalence.equals()解决

weblogic下部署(含JedisResourcePool类引入报错Caused By: java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor()Lcom/google/common/util/concurrent/ListeningExecutorService;解决

把解决思路与解决办法共享给大家。

背景:项目引入REDIS在tomcat8.5下开发环境功能正常,当打成war包部署在weblogic下部署报错,报错信息如下:

 com.tydic.back.utils.DicSaleWebContextListern failed: org.springframework.beans.factory.BeanCreationException:
 Error creating bean with name 'redis.operation.jodisPoolClient' defined in class path resource [redis-config/redis.xml]: 
Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Could not instantiate bean class [com.tydic.portal.common.redis.JodisPoolClient]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError:
 com.google.common.base.Equivalence.equals()Lcom/google/common/base/Equivalence;.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redis.operation.jodisPoolClient' defined in class path resource [redis-config/redis.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Could not instantiate bean class [com.tydic.portal.common.redis.JodisPoolClient]: Constructor threw exception; nested exception is
 java.lang.NoSuchMethodError: com.google.common.base.Equivalence.equals()Lcom/google/common/base/Equivalence;
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:285)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:993)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:897)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.tydic.portal.common.redis.JodisPoolClient]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.google.common.base.Equivalence.equals()Lcom/google/common/base/Equivalence;
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:107)
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:277)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:993)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:897)
        Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: com.google.common.base.Equivalence.equals()Lcom/google/common/base/Equivalence;
        at com.google.common.cache.LocalCache$Strength$1.defaultEquivalence(LocalCache.java:393)
        at com.google.common.cache.CacheBuilder.getKeyEquivalence(CacheBuilder.java:297)
        at com.google.common.cache.LocalCache.(LocalCache.java:246)
        at com.google.common.cache.LocalCache$LocalManualCache.(LocalCache.java:4772)
        at com.google.common.cache.CacheBuilder.build(CacheBuilder.java:804)
        Truncated. see log file for complete stacktrace

一、经过初步分析com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor在工程引入JAR包中存在,并且有此方法。但是部署在weblogic却报方法不存在。初步定位为JAR包冲突。

1、网上建议更新guava.jar到18.0版本。升级完成后部署jar包后报错依旧存在。

gradle脚本:

  compile ("com.google.guava:guava:18.0")

2、考虑当前war包下的jar与weblogic下jar存在冲突。解决方案:指定对应的代码为引入war包中的lib包。在工程webligc.xml下设定  prefer-application-packages属性,把当前的jar指定为工程中代码。

具体实现如下:

  
       
      
            com.google.common.*
       
  

如此解决后,jar包冲突问题就迎刃而解了。

 

 

 

你可能感兴趣的:(工作心得)