首页

因缺commons-pool.jar包报出"java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool$Config"

标签:exception,异常,error,redis,dubbo,commons-pool-1.5.5.jar,pom,maven     发布时间:2016-11-15   

一、问题描述

dubbo项目的将注册中心zookeeper(zookeeper://127.0.0.1:2181)改为redis的(redis://127.0.0.1:6379),无法正常启动,报出“java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool$Config..”异常,具体如下所示

信息: Initializing Spring root WebApplicationContext@b@[dubbo-soa-provider][INFO] [2016-11-15 12:13:41] org.springframework.web.context.ContextLoader.initWebApplicationContext(285) | Root WebApplicationContext: initialization started@b@[dubbo-soa-provider][INFO] [2016-11-15 12:13:42] org.springframework.context.support.AbstractApplicationContext.prepareRefresh(510) | Refreshing Root WebApplicationContext: startup date [Tue Nov 15 12:13:42 CST 2016]; root of context hierarchy@b@[dubbo-soa-provider][INFO] [2016-11-15 12:13:42] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(317) | Loading XML bean definitions from file [D:\WorkSpace\NJ\project\dubbo-soa-provider\target\classes\spring-dubbo.xml]@b@[dubbo-soa-provider][INFO] [2016-11-15 12:13:42] ?.?(?) | using logger: com.alibaba.dubbo.common.logger.log4j.Log4jLoggerAdapter@b@[dubbo-soa-provider][INFO] [2016-11-15 12:13:42] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(317) | Loading XML bean definitions from file [D:\WorkSpace\NJ\project\dubbo-soa-provider\target\classes\spring.xml]@b@[dubbo-soa-provider][INFO] [2016-11-15 12:13:42] com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(107) |  [DUBBO] The service ready on spring started. service: com.xwood.globel.iprovider.ISessionProvider, dubbo version: 2.5.3, current host: 127.0.0.1@b@[dubbo-soa-provider][INFO] [2016-11-15 12:13:43] com.alibaba.dubbo.config.ServiceConfig.exportLocal(510) |  [DUBBO] Export dubbo service com.xwood.globel.iprovider.ISessionProvider to local registry, dubbo version: 2.5.3, current host: 127.0.0.1@b@[dubbo-soa-provider][INFO] [2016-11-15 12:13:43] com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(470) |  [DUBBO] Export dubbo service com.xwood.globel.iprovider.ISessionProvider to url dubbo://10.10.10.27:20880/com.xwood.globel.iprovider.ISessionProvider?anyhost=true&application=bss-provider&dubbo=2.5.3&interface=com.xwood.globel.iprovider.ISessionProvider&methods=get&pid=2724&side=provider&timestamp=1479183222975, dubbo version: 2.5.3, current host: 127.0.0.1@b@[dubbo-soa-provider][INFO] [2016-11-15 12:13:43] com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(481) |  [DUBBO] Register dubbo service com.xwood.globel.iprovider.ISessionProvider url dubbo://10.10.10.27:20880/com.xwood.globel.iprovider.ISessionProvider?anyhost=true&application=bss-provider&dubbo=2.5.3&interface=com.xwood.globel.iprovider.ISessionProvider&methods=get&pid=2724&side=provider&timestamp=1479183222975 to registry registry://127.0.0.1:6379/com.alibaba.dubbo.registry.RegistryService?application=bss-provider&dubbo=2.5.3&pid=2724&registry=redis&timestamp=1479183222954, dubbo version: 2.5.3, current host: 127.0.0.1@b@[dubbo-soa-provider][INFO] [2016-11-15 12:13:43] com.alibaba.dubbo.remoting.transport.AbstractServer.<init>(69) |  [DUBBO] Start NettyServer bind /0.0.0.0:20880, export /10.10.10.27:20880, dubbo version: 2.5.3, current host: 127.0.0.1@b@[dubbo-soa-provider][ERROR] [2016-11-15 12:13:43] org.springframework.web.context.ContextLoader.initWebApplicationContext(336) | Context initialization failed@b@java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool$Config@b@    at com.alibaba.dubbo.registry.redis.RedisRegistry.<init>(RedisRegistry.java:88)@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.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:54)@b@    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:53)@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@Caused by: java.lang.ClassNotFoundException: org.apache.commons.pool.impl.GenericObjectPool$Config@b@    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)@b@    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)@b@    ... 51 more@b@2016-11-15 12:13:43 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.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool$Config@b@    at com.alibaba.dubbo.registry.redis.RedisRegistry.<init>(RedisRegistry.java:88)@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.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:54)@b@    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:53)@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@Caused by: java.lang.ClassNotFoundException: org.apache.commons.pool.impl.GenericObjectPool$Config@b@    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)@b@    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)@b@    ... 51 more@b@2016-11-15 12:13:43 org.apache.catalina.core.StandardContext start@b@严重: Error listenerStart@b@2016-11-15 12:13:43 org.apache.catalina.core.StandardContext start@b@严重: Context [/dubbo-soa-provider] startup failed due to previous errors@b@2016-11-15 12:13:43 org.apache.catalina.core.ApplicationContext log@b@信息: Closing Spring root WebApplicationContext@b@[dubbo-soa-provider][INFO] [2016-11-15 12:13:43] org.springframework.context.support.AbstractApplicationContext.doClose(862) | Closing Root WebApplicationContext: startup date [Tue Nov 15 12:13:42 CST 2016]; root of context hierarchy@b@2016-11-15 12:13:43 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc@b@严重: The web application [/dubbo-soa-provider] registered the JBDC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.@b@2016-11-15 12:13:43 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc@b@严重: The web application [/dubbo-soa-provider] registered the JBDC driver [com.alibaba.druid.mock.MockDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.@b@2016-11-15 12:13:43 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads@b@严重: The web application [/dubbo-soa-provider] appears to have started a thread named [New I/O server boss #1 ([id: 0x17b6dd83, /0.0.0.0:20880])] but has failed to stop it. This is very likely to create a memory leak.@b@2016-11-15 12:13:43 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads@b@严重: The web application [/dubbo-soa-provider] appears to have started a thread named [dubbo-remoting-server-heartbeat-thread-1] but has failed to stop it. This is very likely to create a memory leak.@b@2016-11-15 12:13:43 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads@b@严重: The web application [/dubbo-soa-provider] appears to have started a thread named [DubboRegistryFailedRetryTimer-thread-1] but has failed to stop it. This is very likely to create a memory leak.

二、解决办法

1. 如果是maven项目,直接在pom.xml添加依赖关系,如下

<dependency>@b@   <groupId>commons-pool</groupId>@b@   <artifactId>commons-pool</artifactId>@b@   <version>1.5.5</version>@b@</dependency>

2. 如没下载下来,可以直接到本站的maven中心库下载jar包(commons-pool-1.5.5.jar)或pom.xml(commons-pool-1.5.5.pom)文件,或到maven2官方路径(/commons-pool/commons-pool/)下载


3. 如报“java.lang.NoSuchMethodError: redis.clients.jedis.JedisPool.<init>(Lorg/apache/commons/pool/impl/GenericObjectPool$Config;Ljava/lang/String;II)V”

参考其他解决方法