I am running Keycloak with the Tomcat adapter. But, when I try to get the KeycloakPrincipal, it errors out with this;
java.lang.ClassCastException: org.keycloak.KeycloakPrincipal cannot be cast to org.keycloak.KeycloakPrincipal
My code is very simple and my environment is setup exactly like the KeyCloak docs say it should be.
{
HttpServletRequest request = (HttpServletRequest)getApp().getFromUserStorage(HttpServletRequest.class.getName());
KeycloakPrincipal kcp = (KeycloakPrincipal) request.getUserPrincipal();
}
Any ideas as to what is wrong here? The only solutions I've found by googling have to do with Maven configuration, but Maven isn't being used here.