I created an user storage SPI which is to do authentication for users in external database, I can list all users in the "Users" page of KeyCloak and user can log in from keycloak log in page http://127.0.0.1:8080/auth/realms/dev/account/. But if I want to get access token from http://127.0.0.1:8080/auth/realms/dev/protocol/openid-connect/token, KeyCloak throws exception as below. If I set cache policy as "DEFAULT", KeyCloak works well.
09:18:04,972 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-3) Uncaught server error: java.lang.NullPointerException
at org.keycloak.models.utils.KeycloakModelUtils.resolveAttribute(KeycloakModelUtils.java:415)
at org.keycloak.protocol.oidc.mappers.UserAttributeMapper.setClaim(UserAttributeMapper.java:101)
at org.keycloak.protocol.oidc.mappers.AbstractOIDCProtocolMapper.setClaim(AbstractOIDCProtocolMapper.java:119)
at org.keycloak.protocol.oidc.mappers.AbstractOIDCProtocolMapper.transformAccessToken(AbstractOIDCProtocolMapper.java:81)
at org.keycloak.protocol.oidc.TokenManager.transformAccessToken(TokenManager.java:553)
at org.keycloak.protocol.oidc.TokenManager.createClientAccessToken(TokenManager.java:411)
at org.keycloak.protocol.oidc.TokenManager$AccessTokenResponseBuilder.generateAccessToken(TokenManager.java:712)
at org.keycloak.protocol.oidc.endpoints.TokenEndpoint.resourceOwnerPasswordCredentialsGrant(TokenEndpoint.java:609)
at org.keycloak.protocol.oidc.endpoints.TokenEndpoint.processGrantRequest(TokenEndpoint.java:190)