Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tomcat 9 redis implementation throws ClassCastException on startup #407

Open
emmaLP opened this issue May 14, 2019 · 5 comments
Open

tomcat 9 redis implementation throws ClassCastException on startup #407

emmaLP opened this issue May 14, 2019 · 5 comments

Comments

@emmaLP
Copy link

emmaLP commented May 14, 2019

Running application with docker in tomcat 9, JRE8 and implemented redis session manager.

The tomcat lib folder contains the following jars:

  • jedis-2.9.0.jar
  • memcached-session-manager-tc9-2.3.0.jar
  • memcached-session-manager-2.3.0.jar

context.xml file contains the following config:
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager" memcachedNodes="redis://${tomcat.session.cache}:6379" sticky="false" requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$" />
Versions:
Tomcat 9.0.17.0
JVM: 1.8.0_212-8u212-b01-1~deb9u1-b01

When starting the docker image, the following error occurs during start up:

14-May-2019 10:09:09.059 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal The session manager failed to start
 org.apache.catalina.LifecycleException: Failed to start component [MemcachedBackupSessionManager[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/hello]]]
        at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:441)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:978)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1850)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
        at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:773)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1577)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
        at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424)
        at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:929)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
        at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:928)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:634)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
Caused by: java.lang.RuntimeException: Could not create transcoder factory.
        at de.javakaffee.web.msm.MemcachedSessionService.getTranscoderFactory(MemcachedSessionService.java:507)
        at de.javakaffee.web.msm.MemcachedSessionService.createTranscoderService(MemcachedSessionService.java:499)
        at de.javakaffee.web.msm.MemcachedSessionService.startInternal(MemcachedSessionService.java:453)
        at de.javakaffee.web.msm.MemcachedBackupSessionManager.startInternal(MemcachedBackupSessionManager.java:540)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        ... 40 more
Caused by: java.lang.ClassCastException: class de.javakaffee.web.msm.JavaSerializationTranscoderFactory
        at java.lang.Class.asSubclass(Class.java:3404)
        at de.javakaffee.web.msm.MemcachedSessionService.loadTranscoderFactoryClass(MemcachedSessionService.java:541)
        at de.javakaffee.web.msm.MemcachedSessionService.createTranscoderFactory(MemcachedSessionService.java:526)
        at de.javakaffee.web.msm.MemcachedSessionService.getTranscoderFactory(MemcachedSessionService.java:505)
        ... 44 more

I have tried other transcoder classes but they all result in a ClassCastException

Please could you advise whether I am missing any configuration or there is an issue with support for Tomcat 9 with a redis implementation

@emmaLP
Copy link
Author

emmaLP commented May 14, 2019

Tried the latest jars in the tomcat lib folder

jedis-3.0.1.jar
memcached-session-manager-tc9-2.3.2.jar
memcached-session-manager-2.3.2.jar

However, I still get the same error

@jugaji
Copy link

jugaji commented Sep 9, 2022

Hi!
Did you resolve this issue? I'm in the same situation.

@LLY-SC
Copy link

LLY-SC commented Sep 9, 2022 via email

@dilowagner
Copy link

I had the similar issue.
But in my case, I was putting the wrong path in the Context in server.xml
This is works to me:

Changing this

<Context path="/" reloadable="false">
    <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
             memcachedNodes="redis://localhost"
             sticky="true"
             ... others configs
             storageKeyPrefix="static:mykey" />
</Context>

Using /app

<Context path="/app" reloadable="false">
    <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
             memcachedNodes="redis://localhost"
             sticky="true"
             ... others configs
             storageKeyPrefix="static:mykey" />
</Context>

Docker Image: tomcat:9-jdk17-corretto-al2

The tomcat lib folder contains the following jars:

  • jedis-3.0.0.jar
  • memcached-session-manager-tc9-2.3.2.jar
  • memcached-session-manager-2.3.2.jar

@LLY-SC
Copy link

LLY-SC commented Oct 24, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants