AmadeusITGroup / HttpSessionReplacer

Store JEE Servlet HttpSessions in Redis
MIT License
49 stars 33 forks source link

Cannot instantiate Redis Repository, Tomcat #62

Open vlasopoulos opened 1 year ago

vlasopoulos commented 1 year ago

I'm really sorry if this is my own issue because I am an amateur but I've been trying for about 3 days now and I haven't found anything helpful anywhere.

No matter how I set the provider to redis either with OPTS as it is in the documentation: -javaagent:/usr/local/tomcat/session-agent/session-agent.jar=provider=redis or in web.xml:

<context-param>
    <param-name>com.amadeus.session.repository.factory</param-name>
    <param-value>redis</param-value>
</context-param>

I get the error that it can't instantiate redis:

Caused by: java.lang.IllegalArgumentException: Unable to load or instantiate SessionRepositoryFactory. Id=redis, Implementation=redis
    at com.amadeus.session.servlet.SessionHelpers.repository(SessionHelpers.java:342)
    at com.amadeus.session.servlet.SessionHelpers.initSessionManagement(SessionHelpers.java:190)
    at com.amadeus.session.servlet.SessionHelpers.initSessionManagement(SessionHelpers.java:149)

Caused by: java.lang.ClassNotFoundException: redis
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1951)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1794)
    at com.amadeus.session.servlet.SessionHelpers.newInstance(SessionHelpers.java:379)
    at com.amadeus.session.servlet.SessionHelpers.repositoryOrDefault(SessionHelpers.java:363)
    at com.amadeus.session.servlet.SessionHelpers.repository(SessionHelpers.java:340)

This happens in Tomcat 7,8,9 and 10 The .war is the Sample Application that Tomcat provides.

Without Session Repository it works fine, but I can't get it to work with Redis. I've tried giving every possible parameter through -D option or through web.xml but nothing else happens. I've also tried pre-built versions of session-agent and session-replacement (4.10 even going back to 2.0) but it's the same.

bferrenq commented 1 year ago

Hello, my few cents, from https://github.com/AmadeusITGroup/HttpSessionReplacer#configuration-1, it seems you should use: provider=factory class for repository or name of the provider. So for you provider=redis, no? Also from the same readme, it seems redis is the default implementation, so I am wondering if you have anything to setup in the end?

vlasopoulos commented 1 year ago

I think I found the issue, In InitializeSessionManagement.java I found the provider mapping LINE 48 providerMapping.put("redis", "com.amadeus.session.repository.redis.JedisSessionRepositoryFactory"); So when I pass provider=com.amadeus.session.repository.redis.JedisSessionRepositoryFactory it works but the mapping doesn't work if I pass provider=redis