Hello Jonathan, It is not exactly the same :), look at the "$2" appended at the end.This is an "anonymous inner class" [1]
Cheers, Luis [1] https://stackoverflow.com/questions/11388840/java-compiled-classes-contain-dollar-signs El vie., 8 may. 2020 a las 11:52, Jonathan Yom-Tov (< jonathan.yom...@sysaid.com>) escribió: > This is very odd. I ran Tomcat with -verbose:class (see relevant output > below). The class is being loaded twice from the same location, I'm > guessing by two different class loaders. How can that be? > > [Loaded org.redisson.tomcat.RedissonSessionManager from > file:/C:/dev/tomcat.9.0.19/lib/redisson-tomcat-9-3.12.2.jar] > [Loaded org.redisson.tomcat.RedissonSessionManager$2 from > file:/C:/dev/tomcat.9.0.19/lib/redisson-tomcat-9-3.12.2.jar] > > On Fri, May 8, 2020 at 11:04 AM Olaf Kock <tom...@olafkock.de> wrote: > > > > > On 08.05.20 09:37, Jonathan Yom-Tov wrote: > > > Thanks Mark. Just tried that. I put the redisson-tomcat jar outside of > > > WEB-INF/lib and added it with scope provided. I get the exact same > issue. > > > What am I doing wrong? > > > > Make sure, it's actually gone from your webapp. Depending on the > > deployment technique I've seen removed files to persist from previous > > deployments. > > > > You might need to fully undeploy, then deploy the new version without > > the jar in question. But inspect the runtime environment to make sure > > you only have a single library accessible. Having the same class > > available two different ways is a recipe for disaster, don't fix it my > > messing with the classloader: Fix it by eliminating one of them. > > > > You might also check if you're not accessing any wrapped object, e.g. by > > inspecting getManager(session).getClass().getName(). > > > > Olaf > > > > > > > > > Here's my code: > > > > > > HttpSession session = httpServletRequest.getSession(false); > > > try { > > > RedissonSessionManager rsm = (RedissonSessionManager) > > getManager(session); > > > } catch (Exception e) { > > > e.printStackTrace(); > > > } > > > > > > private Manager getManager(HttpSession session) throws Exception { > > > > > > Field facadeSessionField = > > > StandardSessionFacade.class.getDeclaredField("session"); > > > facadeSessionField.setAccessible(true); > > > StandardSession stdSession = (StandardSession) > > > facadeSessionField.get(session); > > > > > > return stdSession.getManager(); > > > } > > > > > > > > > > > > On Thu, May 7, 2020 at 11:52 PM Mark Thomas <ma...@apache.org> wrote: > > > > > >> On 07/05/2020 21:36, Jonathan Yom-Tov wrote: > > >>> My application uses Redisson (a client which persists the session to > > >>> Redis). There are two Redisson jar files located in > $CATALINA_HOME/lib, > > >> so > > >>> if I understand the docs correctly they're loaded by the common class > > >>> loader. > > >>> > > >>> I want to access the RedissonSessionManager class during a request. > The > > >>> problem is that if I do something like RedissonSessionManager > manager = > > >>> (RedissonSessionManager) session.getManager() I get a > > ClassCastException, > > >>> presumably because they were loaded by different class loaders. > > >>> > > >>> Will it help if I somehow access the common class loader for this? If > > so > > >>> how can I do that? If not is there some other way I can achieve this? > > >> Make sure you don't have those JARs in your application's WEB-INF/lib > as > > >> well as $CATALINA_BASE/lib. > > >> > > >> In any recent version of Tomcat any JAR in $CATALINA_BASE/lib will be > > >> visible to your application. > > >> > > >> Mark > > >> > > >> --------------------------------------------------------------------- > > >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > > >> For additional commands, e-mail: users-h...@tomcat.apache.org > > >> > > >> > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > > For additional commands, e-mail: users-h...@tomcat.apache.org > > > > > > -- > [image: SysAid Technologies] > < > http://www.sysaid.com/?utm_source=signature&utm_medium=email&utm_campaign=sysaid-logo > > > Jonathan Yom-Tov > Senior Architect > jonathan.yom...@sysaid.com > Phone (IL): +972 (3) 533-3675 Ext. 932 > [image: SysAid Technologies] > < > https://www.sysaid.com/?utm_source=signature&utm_medium=email&utm_campaign=sysaid-logo-icon > > > [image: SysAid on Facebook] <https://www.facebook.com/SysAidIT> > [image: > SysAid on Twitter] <https://twitter.com/sysaid> [image: SysAid on > Linked-in] <https://www.linkedin.com/company/sysaid-technologies-ltd> > [image: > SysAid on YouTube] <https://www.youtube.com/user/SysAidIT> [image: > SysAid > on Instagram] <https://www.instagram.com/sysaid_technologies/> > [image: Banner] <https://www.sysaid.com/sig-link> > -- "Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better." - Samuel Beckett