tomcat redis 存放session NoClassDefFoundError

J2EE 码拜 10年前 (2015-04-03) 2194次浏览 0个评论

tomcat7.055、redis2.8、jedis.jar、common-pool2.2.jar、tomcat-redissession-manager-1.2-tomcat-7.jar

将上面的3个jar包放入tomcat下的lib目录

修改content.xml
添加:

<Valve className="com.radiadesign.catalina.session.RedisSessionHandlerValve" />
	<Manager className="com.radiadesign.catalina.session.RedisSessionManager"
		host="localhost"
		port="6379" 
		database="0"
		maxInactiveInterval="60"
	/>

启动tomcat时,报错,无法成功启动tomcat。
以下是错误日志:

八月 12, 2014 12:43:16 下午 org.apache.tomcat.util.digester.Digester startElement
严重: Begin event threw error
java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool$Config
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2532)
	at java.lang.Class.getConstructor0(Class.java:2842)
	at java.lang.Class.newInstance(Class.java:345)
	at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:145)
	at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1288)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2786)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:648)
	at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1561)
	at org.apache.catalina.startup.ContextConfig.processContextConfig(ContextConfig.java:637)
	at org.apache.catalina.startup.ContextConfig.contextConfig(ContextConfig.java:580)
	at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:837)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:385)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
	at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:110)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1247)
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1898)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.pool.impl.GenericObjectPool$Config
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	... 37 more

八月 12, 2014 12:43:16 下午 org.apache.catalina.startup.HostConfig deployDirectory
严重: Error deploying web application directory C:\Apache Software Foundation\tomcat7\tomcat3\apache-tomcat-7.0.55\webapps\docs
java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool$Config
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2532)
	at java.lang.Class.getConstructor0(Class.java:2842)
	at java.lang.Class.newInstance(Class.java:345)
	at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:145)
	at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1288)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2786)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:648)
	at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1561)
	at org.apache.catalina.startup.ContextConfig.processContextConfig(ContextConfig.java:637)
	at org.apache.catalina.startup.ContextConfig.contextConfig(ContextConfig.java:580)
	at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:837)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:385)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
	at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:110)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1247)
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1898)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.pool.impl.GenericObjectPool$Config
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	... 37 more

在新加入的3个jar包中,均没有需要用到org.apache.commons.pool.impl.GenericObjectPool$Config的地方,redis引用的是
org.apache.commons.pool2.impl.GenericObjectPool$Config,不知道怎么会出现这个错。

在tomcat-redissession-manager-1.2-tomcat-7.jar的源码中有一个类RedisSessionManager在Eclipse中发现有问题。
这个类中有处代码for (Valve valve : getContext().getPipeline().getValves()) 这里的getContext() 方法报错,提示没有该方法,并且在该类的父类ManagerBase中也没有找到该方法。

tomcat redis 存放session NoClassDefFoundError
25分
会不会是两个类冲突了

org.apache.commons.pool2.impl.GenericObjectPool$Config

和org.apache.commons.pool.impl.GenericObjectPool$Config

tomcat redis 存放session NoClassDefFoundError
问题已经解决了。不是两个包冲突的原因。tomcat7环境下只能使用jedis版本不能太高,我之后改用jedis2.2+common-pool1.6就好了。
在这里也要感慨一下,网上好多人啊,转文章也他妈的不验证一下,你抄我的,我转你的,至于结果行不行,根本就没有验证过。这样的人不少
tomcat redis 存放session NoClassDefFoundError
50分
引用 2 楼 crazypandariy 的回复:

问题已经解决了。不是两个包冲突的原因。tomcat7环境下只能使用jedis版本不能太高,我之后改用jedis2.2+common-pool1.6就好了。
在这里也要感慨一下,网上好多人啊,转文章也他妈的不验证一下,你抄我的,我转你的,至于结果行不行,根本就没有验证过。这样的人不少

问题百度一下打开10个网页, 有7、8个都是完全一样的

tomcat redis 存放session NoClassDefFoundError
25分
楼主 我想问下 你这样做session共享,如果用spring Security 做权限管理 如何实现session管理 只允许一个用户登录
tomcat redis 存放session NoClassDefFoundError
博主,我跟你一样的包。启动tomcat7怎么报版本不统一:

java.lang.UnsupportedClassVersionError: com/radiadesign/catalina/session/RedisSessionHandlerValve : Unsupported major.minor version 51.0
tomcat redis 存放session NoClassDefFoundError
引用 5 楼 djyangbeiyan 的回复:

博主,我跟你一样的包。启动tomcat7怎么报版本不统一:

java.lang.UnsupportedClassVersionError: com/radiadesign/catalina/session/RedisSessionHandlerValve : Unsupported major.minor version 51.0

解决没有

tomcat redis 存放session NoClassDefFoundError
我也遇到同样的问题了,使用JDK 7解决

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明tomcat redis 存放session NoClassDefFoundError
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!