Redis + Jedis + Spring整合遇到的异常(转)

 

项目中需要用到缓存,经过比较后,选择了redis,客户端使用jedis连接,也使用到了spring提供的spring-data-redis。配置正确后启动tomcat,发现如下异常:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisTemplate' defined in class path resource [spring.xml]: Initialization of bean failed; nested exception is java.lang.VerifyError: Bad type on operand stack

Exception Details:

  Location:

    org/springframework/data/redis/connection/jedis/JedisConnectionFactory.afterPropertiesSet()V @109: invokespecial

  Reason:

    Type 'redis/clients/jedis/JedisPoolConfig' (current frame, stack[3]) is not assignable to 'org/apache/commons/pool2/impl/GenericObjectPoolConfig'

  Current Frame:

    bci: @109

    flags: { }

    locals: { 'org/springframework/data/redis/connection/jedis/JedisConnectionFactory' }

    stack: { 'org/springframework/data/redis/connection/jedis/JedisConnectionFactory', uninitialized 73, uninitialized 73, 'redis/clients/jedis/JedisPoolConfig', 'java/lang/String', integer, integer, 'java/lang/String' }

  Bytecode:

    0000000: 2ab4 000d c700 3d2a bb00 1759 2ab4 0003

    0000010: 2ab4 0004 b700 18b5 000d 2ab4 0019 b800

    0000020: 1a99 000e 2ab4 000d 2ab4 0019 b600 1b2a

    0000030: b400 059e 000e 2ab4 000d 2ab4 0005 b600

    0000040: 1c2a b400 0699 002e 2abb 001d 592a b400

    0000050: 0a2a b400 0db6 001e 2ab4 000d b600 1f2a

    0000060: b400 0db6 0020 2ab4 000d b600 21b7 0022

    0000070: b500 07b1                              

  Stackmap Table:

    same_frame(@47)

    same_frame(@65)

    same_frame(@115)

 

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)

at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:442)

at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:416)

at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:550)

at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)

at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)

at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:303)

... 39 more

Caused by: java.lang.VerifyError: Bad type on operand stack

Exception Details:

  Location:

    org/springframework/data/redis/connection/jedis/JedisConnectionFactory.afterPropertiesSet()V @109: invokespecial

  Reason:

    Type 'redis/clients/jedis/JedisPoolConfig' (current frame, stack[3]) is not assignable to 'org/apache/commons/pool2/impl/GenericObjectPoolConfig'

  Current Frame:

    bci: @109

    flags: { }

    locals: { 'org/springframework/data/redis/connection/jedis/JedisConnectionFactory' }

    stack: { 'org/springframework/data/redis/connection/jedis/JedisConnectionFactory', uninitialized 73, uninitialized 73, 'redis/clients/jedis/JedisPoolConfig', 'java/lang/String', integer, integer, 'java/lang/String' }

  Bytecode:

    0000000: 2ab4 000d c700 3d2a bb00 1759 2ab4 0003

    0000010: 2ab4 0004 b700 18b5 000d 2ab4 0019 b800

    0000020: 1a99 000e 2ab4 000d 2ab4 0019 b600 1b2a

    0000030: b400 059e 000e 2ab4 000d 2ab4 0005 b600

    0000040: 1c2a b400 0699 002e 2abb 001d 592a b400

    0000050: 0a2a b400 0db6 001e 2ab4 000d b600 1f2a

    0000060: b400 0db6 0020 2ab4 000d b600 21b7 0022

    0000070: b500 07b1                              

  Stackmap Table:

    same_frame(@47)

    same_frame(@65)

    same_frame(@115)

 

at java.lang.Class.getDeclaredConstructors0(Native Method)

at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493)

at java.lang.Class.getDeclaredConstructors(Class.java:1901)

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:230)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:972)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:945)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)

... 50 more

 

非常奇怪,由于google的访问限制,百度了半天也没什么结果,我就知道google一定可以的,果断FQ搜索,果然没有让我失望,

google结果链接:http://stackoverflow.com/questions/22704518/jedispoolconfig-is-not-assignable-to-genericobjectpoolconfig

 

看情况应该是jar包版本问题,我目前的版本为:jedis-2.1.0.jar + spring-data-redis-1.3.0.RELEASE.jar。

按照提示我将jedis升级成了jedis-2.4.2.jar。

再次运行,成功!!

 

哎,百度,不争气啊

http://zhaobing315.iteye.com/blog/2082189

 

时间: 2024-10-25 15:31:08

Redis + Jedis + Spring整合遇到的异常(转)的相关文章

redis安装,redis项目以来,redis和spring整合,redis的service,redis的service实现类

一.redis安装: Redis-3.2.6.tar.gz安装,参考方式: 用源码工程来编译安装 1.  到官网下载最新stable版,这里使用的是:redis-3.2.6.tar.gz 2.  cd /usr/local   3.  make redis-src 4.  tar -zxvf    redis-3.2.6.tar.gz  -C  ./redis-src/ 2.解压源码并进入目录cd  /usr/local/redis-src/redis-3.2.6 3. 先执行make,检查是否

redis和spring整合

pom构建: [html] view plain copy  print? <modelVersion>4.0.0</modelVersion>   <groupId>com.x.redis</groupId>   <artifactId>springredis</artifactId>   <version>0.0.1-SNAPSHOT</version>      <dependencies> 

struts2+Hibernate+spring整合问题(异常

问题描述 异常信息:exceptionUnable to instantiate Action, loginAction, defined for 'loginAction' in namespace '/'loginActioncom.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:318)com.opensymphony.xwork2.DefaultActionInvo

征服 Redis + Jedis

[本文转载于征服 Redis + Jedis] 用Memcached,对于缓存对象大小有要求,单个对象不得大于1MB,且不支持复杂的数据类型,譬如SET 等.基于这些限制,有必要考虑Redis!   相关链接: 征服 Redis 征服 Redis + Jedis 征服 Redis + Jedis + Spring (一)-- 配置&常规操作(GET SET DEL) 征服 Redis + Jedis + Spring (二)-- 哈希表操作(HMGET HMSET) 征服 Redis + Jed

spring整合hibernate出现sessionFactory的bean创建异常错误

问题描述 spring整合hibernate出现sessionFactory的bean创建异常错误 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; neste

Redis 缓存 + Spring 的集成示例

SpringSession和Redis实现Session跨域 http://www.ithao123.cn/content-11111681.html   tomcat中创建session很耗服务器内存 原生session与session in redis对比下面是从stackoverflow上找到的一些观点: Using something like Redis for storing sessions is a great way to get more performance out of

Redis 缓存 + Spring 的集成示例(转)

<整合 spring 4(包括mvc.context.orm) + mybatis 3 示例>一文简要介绍了最新版本的 Spring MVC.IOC.MyBatis ORM 三者的整合以及声明式事务处理.现在我们需要把缓存也整合进来,缓存我们选用的是 Redis,本文将在该文示例基础上介绍 Redis 缓存 + Spring 的集成.关于 Redis 服务器的搭建请参考博客<Redhat5.8 环境下编译安装 Redis 并将其注册为系统服务>. 1. 依赖包安装 pom.xml

ubuntu 14.10 + tomcat + spring 整合

问题描述 ubuntu 14.10 + tomcat + spring 整合 严重: Error configuring application listener of class com.sun.faces.config.ConfigureListener java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener at org.apache.catalina.loader.WebappClassLoader

springmvc-SpringMVC整合hessian出现异常,求高手解决!!

问题描述 SpringMVC整合hessian出现异常,求高手解决!! 异常信息:严重: Servlet.service() for servlet spring threw exceptionjava.lang.ClassNotFoundException: com.caucho.hessian.client.HessianConnectionException at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappCl