This is probably a classloader issue. The Realm will load classes from the server classloader. Your webapp will also load the same classes in its own classloader. The two types of CrmPrincipal are not assignable so a ClassCastException results. Try placing the CrmPrincipal class in common/lib and removing it from your webapp.

HTH,

Jon

ralf lorenz wrote:
hi there,

i've written my own realm 'CrmJDBCRealm' which extends the 'JDBCRealm' one of catalina.

this realm creates and returns a principal of type 'CrmPrincipalImpl' which
extends 'GenericPrincipal' and implements 'CrmPrincipal'.

'CrmPrincipal' has getter for an 'id' and getter and setter for a 'currentRole' field and extends
'Principal' as well as 'GenericPrincipal' does.


'CrmJDBCRealm', 'CrmPrincipalImpl' and 'CrmPrincipal' are packed together
into a .jar and placed under %CATALINA_HOME%/server/lib

on the other side the application only has the 'CrmPrincipal' included, so it doesn't know
about 'CrmPrincipalImpl'. (even if it does nothing changed!)


in my application i have a 'ChangeRoleAction' that is supposed to update
the 'currentRole' if the user decides to have, only application-wide,
another role. again that's nothing to do with the roles of the user that are known
by the server via the 'GenericPrincipal'.


when i try the following i get an ClassCastException

CrmPrincipal principal = (CrmPrincipal) request.getUserPrincipal();

printing out the name of the class the request gives the 'CrmPrincipalImpl' will be stated.
so the realm works fine but the cast can't be done.


any help?

ralf





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



Reply via email to