Fernando Padilla wrote:

> I have a MyRealm class to lock down my webapp.
>
> That works fine.  I have the jar file with the classes in
> $TOMCAT_HOME/server  and within $WEB_APP/WEB_INF/lib.
>
> The Web App needs to gain access to the username/password given to the
> Realm ( right now I store it in the MyPrincipal class ), to be able to
> login into a backend tier.
>
> I try to cast the Principal ( from getUserPrincipal ), to MyPrincipal, but
> it there is a ClassCastException ( though it is indeed the right class,
> it's from a different class loader.. etc )....
>

Different class loader would not matter if it's a parent of the webapp class
loader, but (as we will see) that is not the case.

>
> Again, I'm trying to bridge the gap between the classloader used by the
> server and the classloader used by the web app.  So that I can cast/use an
> object from one classloader from the other classloader....
>
> Ideas?? Help?? Clue?? Rants?? Raves??
>

In that case, you're not going to be able to do this cast.  The classes placed
in $TOMCAT_HOME/server are loaded by a class loader that is not visible to web
applications (i.e. it is not a parent class loader to the one used for your
web app).

If you have additional information from the MyUserPrincipal class that your
application needs to see, I suggest that you store them as request attributes
or session attributes inside the authenticator.  This will work for anything
that is a String or a Java primitive type (wrapped in the corresponding
wrapper class such as java.lang.Integer for an "int").

>
> just toss 'em out
>
> fern
>

Craig McClanahan



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to