You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Yuri de Wit <yd...@gmail.com> on 2006/06/28 21:55:10 UTC

MyPrincipal cannot be resolved to a type

I have created my own Realm implementation that returns a custom Principal
extending GenericPrincipal (it must extend it). The reason I did that was to
be able to provide additional information about the principal such as the
user display ame and possibly other data in the future.

The Realm implementation works like a charm and it is properly
authenticating users but when I try to access the displayName from my
servlet I get an exception:

"MyPrincipal cannot be resolve to a type"

when trying the following:

((MyPrincipal)request.getUserPrincipal()).getDisplayName();

This error is explained by how the ClassLoader's are chained in Tomcat, i.e.
all the jars contained in server/lib are not visible to any web-app classes.
If I move my custom Realm jar from server/lib to shared/lib the web-app
ClassLoader is able to find MyPrincipal but not GenericPrincipal, which also
make sense.

If I move catalina.jar to common/lib then I may need to move (havent
verified that yet) a bunch of other jars there too otherwise I will have
another ClassNotFoundException for catalina.jar dependencies. If I duplicate
catalina.jar to shared/lib I will get a ClassCastException due to the fact
that the same class loaded by diff classloaders is not considered the same
class).

My question at a high level is: how does one pass custom information from a
realm implementation to web-app servlets?