Memcached和Tomcat 8不兼容

时间:2015-02-04 19:21:35

标签: tomcat grails memcached tomcat8

我正在尝试将Grails应用程序部署到Tomcat 8.0.15中。如果重要,操作系统是CentOS 7,Java版本是1.7.0_71,memcached版本是1.4.20。

我使用Grails Standalone Tomcat plugin将memcached用作会话管理器,并且它在Tomcat 7中运行良好。不幸的是,迁移到Tomcat 8并不像预期的那么简单。

我在其依赖项中找到了这个:de.javakaffee.msm:memcached-session-manager-tc7:1.6.4所以我尝试将其更改为tc8(存在于Maven中)并更新各种其他插件的版本。

不幸的是,我在Tomcat 8上部署应用程序时遇到了一个问题:

04-Feb-2015 16:26:08.371 INFO [http-nio-8080-exec-17] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /opt/tomcat/webapps/ROOT.war
2015-02-04 16:26:18 ERROR [GrailsContextLoaderListener] Error initializing the application: loader constraint violation: when resolving overridden method "de.javakaffee.web.msm.MemcachedBackupSessionManager.changeSessionId(Lorg/apache/catalina/Session;)V" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, de/javakaffee/web/msm/MemcachedBackupSessionManager, and its superclass loader (instance of java/net/URLClassLoader), have different Class objects for the type ger.changeSessionId(Lorg/apache/catalina/Session;)V used in the signature
java.lang.LinkageError: loader constraint violation: when resolving overridden method "de.javakaffee.web.msm.MemcachedBackupSessionManager.changeSessionId(Lorg/apache/catalina/Session;)V" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, de/javakaffee/web/msm/MemcachedBackupSessionManager, and its superclass loader (instance of java/net/URLClassLoader), have different Class objects for the type ger.changeSessionId(Lorg/apache/catalina/Session;)V used in the signature
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2615)
    at java.lang.Class.getDeclaredMethods(Class.java:1860)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    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)

总之,有一个名为changeSessionId的方法被类de.javakaffee.web.msm.MemcachedBackupSessionManager覆盖,但它有一些与类加载器所期望的不同。

我在Google上找不到任何帮助,并尝试更改大量版本和依赖项无效,所以我决定回滚到Tomcat 7.但我想留下这个以防万一找到解决方案。

1 个答案:

答案 0 :(得分:0)

Grails插件使用tomcat7 jar的memcached-session-manager

https://github.com/burtbeckwith/grails-standalone-tomcat-memcached/blob/master/grails-app/conf/BuildConfig.groovy#L25

根据Memcache会话管理器的文档,每个tomcat 6,7& 8有自己的jar https://code.google.com/p/memcached-session-manager/wiki/SetupAndConfiguration