You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Joachim Gjesdal <jo...@ecomda.de> on 2001/08/31 12:43:48 UTC

Realms and classloading

I have a LdapRealm that extends RealmBase and a LdapPrincipal that
implements Principal. These are loaded by the catalina classloader at
startup in order to perform formbased authentication.When the user logs
in and is authenticated by the ldap server, the LdapRealm creates a
LdapPrincipal and stores it in the realm. Then a web application does a
request.getUserPrincipal () to get the principal. This results in
ClassCastException since the LdapPrincipal class is now loaded by the
web applications classloader.

Suggestions on how to solve this would be apprectiated,

joachim gjesdal

Re: Realms and classloading + solution

Posted by Joachim Gjesdal <jo...@ecomda.de>.
The solution was to let the common classloader be responsible for loading
LdapRealmPrincipal and LdapPrincipalUtil (a delegation class).
The catalina classloader is responsible for loading the LdapRealm class.

This way the both webapp classloader and the catalina classloader is able
to get hold of the LdapRealmPrincipal.

The delegation class is there just to avoid that the LdapRealmPrincipal
needs a reference back to to the LdapRealm (which is not accessible from
the common classloader).

joachim


Joachim Gjesdal wrote:

> I have a LdapRealm that extends RealmBase and a LdapPrincipal that
> implements Principal. These are loaded by the catalina classloader at
> startup in order to perform formbased authentication.When the user logs
> in and is authenticated by the ldap server, the LdapRealm creates a
> LdapPrincipal and stores it in the realm. Then a web application does a
> request.getUserPrincipal () to get the principal. This results in
> ClassCastException since the LdapPrincipal class is now loaded by the
> web applications classloader.
>
> Suggestions on how to solve this would be apprectiated,
>
> joachim gjesdal

Re: Realms and classloading

Posted by Joachim Gjesdal <jo...@ecomda.de>.
... forgot to say: I run tomcat 4.0-B7.

Joachim Gjesdal wrote:

> I have a LdapRealm that extends RealmBase and a LdapPrincipal that
> implements Principal. These are loaded by the catalina classloader at
> startup in order to perform formbased authentication.When the user logs
> in and is authenticated by the ldap server, the LdapRealm creates a
> LdapPrincipal and stores it in the realm. Then a web application does a
> request.getUserPrincipal () to get the principal. This results in
> ClassCastException since the LdapPrincipal class is now loaded by the
> web applications classloader.
>
> Suggestions on how to solve this would be apprectiated,
>
> joachim gjesdal