Nullpointer Exception for theme

Hi,
I had a working local keycloak image when I had to nuke all my docker images for another issue. I then brought up my keycloak image again with

version: '3.6'

volumes:
  keycloak_postgres_data: {}

services:
  postgres-keycloak:
      image: postgres:10-alpine
      container_name: postgres
      volumes:
        - keycloak_postgres_data:/var/lib/postgresql/data
      environment:
        POSTGRES_DB: keycloak
        POSTGRES_USER: keycloak
        POSTGRES_PASSWORD: password
        
  keycloak:
      image: jboss/keycloak:4.1.0.Final
      environment:
        DB_VENDOR: POSTGRES
        DB_ADDR: postgres
        DB_DATABASE: keycloak
        DB_USER: keycloak
        DB_PASSWORD: password
        KEYCLOAK_USER: admin
        KEYCLOAK_PASSWORD: testing
      ports:
        - 8088:8080
      volumes:
        - ./themes/puretalent:/opt/jboss/keycloak/themes/puretalent
        - ./themes/fifteenrock:/opt/jboss/keycloak/themes/fifteenrock
      depends_on:
        - postgres-keycloak

The themes mentioned in the volume are present in the same folder and are also in the container when I bring it up. In the Realm Settings, I have tried, setting the theme to my specific theme or to the default theme but I get the same error below. I’ve elided it to the relevant error messages.

keycloak_1 |
keycloak_1 | 01:18:58,781 WARN [org.keycloak.events] (default task-1) type=LOGIN_ERROR, realmId=master, clientId=odin, userId=null, ipAddress=172.20.0.1, error=invalid_user_credentials, auth_method=openid-connect, auth_type=code, response_type=code, redirect_uri=http://localhost:8082/odin/oidc_callback, code_id=9646b75e-273d-473e-a999-643d01d4cc36, response_mode=query
keycloak_1 | 01:18:58,793 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-1) Uncaught server error: java.lang.NullPointerException
keycloak_1 | at org.keycloak.theme.ExtendingThemeManager.loadTheme(ExtendingThemeManager.java:117)
keycloak_1 | at org.keycloak.theme.ExtendingThemeManager.getTheme(ExtendingThemeManager.java:108)
keycloak_1 | at org.keycloak.theme.DefaultThemeManager.getTheme(DefaultThemeManager.java:26)
keycloak_1 | at org.keycloak.theme.DefaultThemeManager.getTheme(DefaultThemeManager.java:21)
keycloak_1 | at org.keycloak.forms.login.freemarker.FreeMarkerLoginFormsProvider.getTheme(FreeMarkerLoginFormsProvider.java:262)
keycloak_1 | at org.keycloak.forms.login.freemarker.FreeMarkerLoginFormsProvider.createResponse(FreeMarkerLoginFormsProvider.java:158)
keycloak_1 | at org.keycloak.forms.login.freemarker.FreeMarkerLoginFormsProvider.createErrorPage(FreeMarkerLoginFormsProvider.java:498)
keycloak_1 | at org.keycloak.services.ErrorPage.error(ErrorPage.java:31)
keycloak_1 | at org.keycloak.authentication.AuthenticationProcessor.handleBrowserException(AuthenticationProcessor.java:728)
keycloak_1 | at org.keycloak.protocol.AuthorizationEndpointBase.handleBrowserAuthenticationRequest(AuthorizationEndpointBase.java:145)
keycloak_1 | at org.keycloak.protocol.oidc.endpoints.AuthorizationEndpoint.buildAuthorizationCodeAuthorizationResponse(AuthorizationEndpoint.java:409)
keycloak_1 | at org.keycloak.protocol.oidc.endpoints.AuthorizationEndpoint.process(AuthorizationEndpoint.java:152)
keycloak_1 | at org.keycloak.protocol.oidc.endpoints.AuthorizationEndpoint.buildGet(AuthorizationEndpoint.java:108)

In Client->->Settings->Login Theme. Select your theme.

Hi,

If your theme has some common resources (as in keycloak theme https://github.com/keycloak/keycloak/tree/master/themes/src/main/resources/theme/keycloak), may be you forgot to declare the type “common” in the keycloak-themes.json (see https://github.com/keycloak/keycloak/blob/master/themes/src/main/resources-community/META-INF/keycloak-themes.json) .

ExtendingThemeManager is missing defensive code that causes some null values to be added to the internal list of themes

Hope this will help.

2 Likes

Hi @fidgi,
Thanks for your reply. I never had to modify the keycloak-themes.json before when it was working for me(before I nuked my docker instances). I tried with the default keycloak theme initially but that did not work too. I got it working by setting the theme in the client settings as detailed above.