I have been cracking my head for the past 3 weeks on this issue and I try my best to explain it in simplest term since I don't have the source code.
- Platform
. Tomcat 7
. Window Server 2008
. JRE 7
- Using Tomcat JAAS realm
Defined in the web application META-INF/context.xml.
<Context>
<Realm className="org.apache.catalina.realm.JAASRealm" appName="ABC" userClassNames="com.abc.xyz" useContextClassLoader="true"/>
- Here's the difficult part since i don't have the source code.
I have WEB-INF/classes/a123 & b123 class files
. This class a123 uses logincontext
. The logincontext has some configuration defined
. This configuration file i believe is part of JAAS realm needs to access b123.
Problem. Class b123 is not found.
I believe this issue is that the Tomcat JAAS realm is on Tomcat Server and cannot find b123 since b123 is under the webappsclassloader.
So as you can see in my context.xml, I did set the useContextClassLoader="true" which I believe by default is webappsclassloader.
I tried putting the b123 in the Tomcat startup classpath which works then but now I believe I have 2 copies of b123.
. b123 under Tomcat server
. b123 under webappsclassloader
I think the issue here a class higher in the class loading hierarchy is trying to access the web apps class in the lower hierarchy. That would definitely fail based on the way class loading delegation work. So the only way i could think which works is to use the Thread context class loader.
As you can see on the context.xml i did set the useContextClassLoader to "true". But how do i set the context class loader through Tomcat configuration since i don't have access to the source code? I guess the context class loader needs to be set before the JAAS realm uses the context class loader.
Any help would be great!