首页

因缺少jedis.jar包报"java.lang.NoSuchMethodError: redis.clients.jedis.JedisPool..."问题

标签:jedis-2.0.0,redis,maven,commons-pool-1.5.5,异常,exception     发布时间:2016-11-15   

一、问题描述

项目是基于dubbo的2.5.3版本,将注册中心zookeeper(zookeeper://127.0.0.1:2181)改为redis的(redis://127.0.0.1:6379),添加redis依赖关系,启动系统报异常“java.lang.NoSuchMethodError: redis.clients.jedis.JedisPool.<init>(Lorg/apache/commons/pool/impl/GenericObjectPool$Config;Ljava/lang/String;II)V”,具体错误日志如下所示

java.lang.NoSuchMethodError: redis.clients.jedis.JedisPool.<init>(Lorg/apache/commons/pool/impl/GenericObjectPool$Config;Ljava/lang/String;II)V@b@    at com.alibaba.dubbo.registry.redis.RedisRegistry.<init>(RedisRegistry.java:130)@b@    at com.alibaba.dubbo.registry.redis.RedisRegistryFactory.getRegistry(RedisRegistryFactory.java:30)@b@    at com.alibaba.dubbo.registry.RegistryFactory$Adpative.getRegistry(RegistryFactory$Adpative.java)@b@    at com.alibaba.dubbo.registry.integration.RegistryProtocol.getRegistry(RegistryProtocol.java:190)@b@    at com.alibaba.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:109)@b@    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:53)@b@    at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:54)@b@    at com.alibaba.dubbo.rpc.Protocol$Adpative.export(Protocol$Adpative.java)@b@    at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:485)@b@    at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:281)@b@    at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:242)@b@    at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:143)@b@    at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:109)@b@    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151)@b@    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)@b@    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)@b@    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:773)@b@    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)@b@    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)@b@    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)@b@    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)@b@    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)@b@    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)@b@    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)@b@    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)@b@    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)@b@    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)@b@    at org.apache.catalina.startup.Embedded.start(Embedded.java:825)@b@    at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558)@b@    at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255)@b@    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)@b@    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)@b@    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)@b@    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)@b@    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)@b@    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)@b@    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)@b@    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)@b@    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)@b@    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)@b@    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)@b@    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)@b@    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)@b@    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)@b@    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)@b@    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)@b@    at java.lang.reflect.Method.invoke(Method.java:597)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)@b@2016-11-15 12:14:38 org.apache.catalina.core.StandardContext listenerStart@b@严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener@b@java.lang.NoSuchMethodError: redis.clients.jedis.JedisPool.<init>(Lorg/apache/commons/pool/impl/GenericObjectPool$Config;Ljava/lang/String;II)V@b@    at com.alibaba.dubbo.registry.redis.RedisRegistry.<init>(RedisRegistry.java:130)@b@    at com.alibaba.dubbo.registry.redis.RedisRegistryFactory.getRegistry(RedisRegistryFactory.java:30)@b@    at com.alibaba.dubbo.registry.RegistryFactory$Adpative.getRegistry(RegistryFactory$Adpative.java)@b@    at com.alibaba.dubbo.registry.integration.RegistryProtocol.getRegistry(RegistryProtocol.java:190)@b@    at com.alibaba.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:109)@b@    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:53)@b@    at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:54)@b@    at com.alibaba.dubbo.rpc.Protocol$Adpative.export(Protocol$Adpative.java)@b@    at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:485)@b@    at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:281)@b@    at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:242)@b@    at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:143)@b@    at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:109)@b@    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151)@b@    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)@b@    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)@b@    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:773)@b@    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)@b@    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)@b@    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)@b@    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)@b@    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)@b@    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)@b@    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)@b@    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)@b@    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)@b@    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)@b@    at org.apache.catalina.startup.Embedded.start(Embedded.java:825)@b@    at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558)@b@    at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255)@b@    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)@b@    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)@b@    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)@b@    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)@b@    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)@b@    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)@b@    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)@b@    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)@b@    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)@b@    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)@b@    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)@b@    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)@b@    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)@b@    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)@b@    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)@b@    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)@b@    at java.lang.reflect.Method.invoke(Method.java:597)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)@b@2016-11-15 12:14:38 org.apache.catalina.core.StandardContext start@b@严重: Error listenerStart

二、解决方法

1. 由于dubbo的2.5.3版本依赖的redis版本是2.0.0,添加正确的依赖关系如下

<dependency>@b@      <groupId>redis.clients</groupId>@b@       <artifactId>jedis</artifactId>@b@       <version>2.0.0</version>@b@</dependency>

2. 离线或在线online下载jedis-2.0.0的jar和pom文件(到本站的maven参考下载,或到maven2官网下载

3. 因为jedis-2.0.0版本依赖的commons-pool-1.5.5,同时下载其jar和pom文件

<<热门下载>>