[keycloak-user] KeycloakPrincipal ClassCastException
Brent Vaughn
Vaughn at climatecontrolgroup.com
Thu Mar 9 18:49:34 EST 2017
Using KeyCloak 2.5.4 and Wildfly 10.1.0
I am attempting to create a JSF component that involves Keycloak. I am getting this exception:
java.lang.ClassCastException: org.keycloak.KeycloakPrincipal cannot be cast to org.keycloak.KeycloakPrincipal
Below is the line of code that throws the exception.
public void encodeBegin(FacesContext context) {
..........
KeycloakPrincipal<KeycloakSecurityContext> kp = (KeycloakPrincipal<KeycloakSecurityContext>) context.getExternalContext().getUserPrincipal();
..........
}
Funny thing is this. The exception is only thrown when the JSF Component is in a separate jar and then added to the project. If I put the code in question directly in the project, it doesn't throw the exception.
Can anyone help me with this?
More information about the keycloak-user
mailing list