-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Olaf,
On 5/8/20 13:19, Olaf Kock wrote: > > On 08.05.20 18:23, Jonathan Yom-Tov wrote: >> Oops, my bad 😁 But that still leaves my original issue: why do I >> get a ClassCastException casting RedissonSessionManager to >> RedissonSessionManager? > > The *only* reason that I've ever seen this happens (e.g. a class > can't be typecast to a legitimate superclass or interface): When > the superclass or interface is available through two different > classloaders. > > The error message omits the classloader, and instead of > > A cannot be cast to B > > /should/ read > > A (from classloader X) cannot be cast to B (from classloader Y) > > You might want to hunt down duplicate classes in the JAR files on > your classpath. Worst case: unpack them all in temporary > directories and check for occurrences of the filename. Make sure > that one doesn't overwrite the other when unzipping. Or unpack them all and let the unzipper tell you if there are any filename collisions. Someone has probably written a "classpath scanner" that will just unzip everything and look for conflicts. - -chris >> On Fri, 8 May 2020, 16:56 Luis Rodríguez Fernández, >> <uo67...@gmail.com> wrote: >> >>> 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-c ontain-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_cam paign=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_ca mpaign=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 >>> > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > -----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl61m+MACgkQHPApP6U8 pFhjxA/+IOLPex2KWzimlFRYCfkrd9bT45Ksrrb0SyKEeUsh4+/SDeZ8e0on9/K2 oCA13GZJj4t6R8gb6OH5/4jCNb15iMSS/N+mz3HR8e8u83IM5tCLzpmCw0wtEEyJ w+lbcyfdiecnBIV3nWvFvS9bgMnBsaHLad2lkojhrdoCl/QdQiJw72vWsuuLsJcm nZr3wYArxbrFFR515KQGaMvhe2LEUw5cti333u2FGi1VTl7f2YXRZ92ZY08QwvAv auToZY56MQ4aVkgf3ck+ju7IlDtnsgHPJ46KgqD8VA7FMq5HuTuwWiaf3NQt75ra 7HK/qFYOwv5Uqo7abxMeQ1WIlD0fzqaJkdzUyuO3ZPnoXshBj3mTRvNd3zH+EWE3 0IFSQ2MOkzDaKd3DqQKdbRGOSroXhHuhJVnlxCUczCsLLGzCr0qzjMnOU9IYj0QR GQUOqLZazn/XlDjWtAPBgXf4CcToG0Pd/IWLyrIh06YeCjOuBurmFPg2a258IdAQ NMjXekn72AWdbBtMdnLMNIIker4aivYPPI36dCz6422cSJI6ct/spqfaTm/jrVS5 DsFNRg7qgcMLavsTl281l+Ano7lgRqpWqywvGvWYzQTJi776+4UYE0lUkcsA6Frm MMknIe9+01aYf2XpDHvEOsM/Wzf+ZcHtnBmhyVaX6uz9mf8uKvU= =2Jus -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org