使用Memcached进行Tomcat会话复制,ClassNotFoundException:com.esotericsoftware.kryo.pool.KryoFactory

时间:2016-06-13 07:34:35

标签: tomcat

使用Memcached进行Tomcat会话复制。 使用kryo-serialize。 启动tomcat时,发生了错误。

在centos6.5上的

Apache Tomcat / 7.0.69。 java版本" 1.7.0_101"。

tomcat错误:

SEVERE: The session manager failed to start
org.apache.catalina.LifecycleException: Failed to start component [de.javakaffee.web.msm.MemcachedBackupSessionManager[]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5593)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1260)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
        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)
Causeotericsoftware.kryo.pool.KryoFactorlassNotFoundExceptioncom.esotericsoftware.kryo.pool.KryoFactorlassNotFoundException: com.esotericsoftware.kryo.pool.KryoFactory
        at de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory.getTranscoder(KryoTranscoderFactory.java:64)
        at de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory.createTranscoder(KryoTranscoderFactory.java:47)
        at de.javakaffee.web.msm.MemcachedSessionService.createTranscoderService(MemcachedSessionService.java:495)
        at de.javakaffee.web.msm.MemcachedSessionService.startInternal(MemcachedSessionService.java:450)
        at de.javakaffee.web.msm.MemcachedBackupSessionManager.startInternal(MemcachedBackupSessionManager.java:554)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        ... 12 more
Caused by: java.lang.ClassNotFoundException: com.esotericsoftware.kryo.pool.KryoFactory
        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)

tomcat的lib目录:

 annotations-api.jar
 asm-3.2.jar
 catalina-ant.jar
 catalina-ha.jar
 catalina.jar
 catalina-tribes.jar
 ecj-4.4.2.jar
 el-api.jar
 jasper-el.jar
 jasper.jar
 jsp-api.jar
 kryo-1.04.jar
 kryo-serializers-0.11.jar
 memcached-session-manager-1.9.3.jar
 memcached-session-manager-tc7-1.9.3.jar
 minlog-1.2.jar
 msm-kryo-serializer-1.9.3.jar
 objenesis-1.4.jar
 reflectasm-1.01.jar
 servlet-api.jar
 spymemcached-2.11.1.jar
 tomcat7-websocket.jar
 tomcat-api.jar
 tomcat-coyote.jar
 tomcat-dbcp.jar
 tomcat-i18n-es.jar
 tomcat-i18n-fr.jar
 tomcat-i18n-ja.jar
 tomcat-jdbc.jar
 tomcat-util.jar
 websocket-api.jar

tomcat content.xml修改:

<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
    memcachedNodes="n1:127.0.0.1:11211"
    sticky="false"
    lockingMode="auto"
    sessionBackupAsync="false"
    requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
    sessionBackupTimeout="1000"
    transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
    />

如何修复此错误? 感谢。

1 个答案:

答案 0 :(得分:1)

你的kryo jar(kryo-1.04.jar)不包含kryo-serializer要求的依赖项,即com.esotericsoftware.kryo.pool.KryoFactory

你需要获得一个更新的kyro包才能使它工作,any of these应该可以完成这项工作。