[keycloak-user] KeycloakPrincipal ClassCastException

John D. Ament john.d.ament at gmail.com
Thu Mar 9 21:14:11 EST 2017


This sounds like you're ending up with duplicate keycloak libraries on your
classpath.  Did you include the keycloak client subsystem?  Are the
keycloak libraries also ending up in your EAR or WAR?

On Thu, Mar 9, 2017 at 9:12 PM Brent Vaughn <Vaughn at climatecontrolgroup.com>
wrote:

> Yes.  But it is an Ear file instead of a War file.  A separate jar in an
> Ear file.
> ________________________________
> From: keycloak-user-bounces at lists.jboss.org <
> keycloak-user-bounces at lists.jboss.org> on behalf of Bill Burke <
> bburke at redhat.com>
> Sent: Thursday, March 9, 2017 7:06:00 PM
> To: keycloak-user at lists.jboss.org
> Subject: Re: [keycloak-user] KeycloakPrincipal ClassCastException
>
> What do you mean "separate jar"?  A jar in the WAR?
>
>
> On 3/9/17 6:49 PM, Brent Vaughn wrote:
> > 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?
> >
> > _______________________________________________
> > keycloak-user mailing list
> > keycloak-user at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/keycloak-user
>
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
>


More information about the keycloak-user mailing list