> From: Matthew Kerle [mailto:[EMAIL PROTECTED] > Class c1 = request.getUserPrincipal().getClass(); //get the > class of the > Principal that tomcat created , which is a MemoryUser instance > Class c2 = MemoryUser.class; // get the class loaded by the > current loader > System.out.println(c1.getClassLoader().getClass.getName()); //prints > "org.apache.catalina.loader.StandardClassLoader" > System.out.println(c2.getClassLoader().getClass.getName()); //prints > "org.apache.catalina.loader.WebappClassLoader" > > Great, so now I've got two different classloaders. Do you know if > there's any way I can cast the Principal to a Memoryuser > object and use > it? do I have to load the MemoryUser class in the current classloader?
Right. So request.getUserPrincipal() returns a class that's loaded by one of Tomcat's classloaders. You need to make sure that when you reference MemoryUser, it's loaded by the same classloader. Thinking aloud here, so apologies to the more experienced folks in the community who will have better ideas... Is MemoryUser.class in any of the jars in your webapp? I'm not entirely sure why there's a second copy of it, loaded by the webapp's classloader, in the system. I'd expect the webapp's classloader to be unable to find the class as your webapp loads and punt the request for the class up the classloader chain, returning the standard classloader's class. But I may be misunderstanding Tomcat's classloaders. - Peter --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]