Keycloak 21.1.2: java.lang.IllegalStateException: Could not find ScriptEngine for script

I am using quay.io/keycloak/keycloak:21.1.2 docker image with Java script adapters, I get below error when the Javascript adapters are executed in the authentication flow

keycloak-1 keycloak 2023-09-26 11:19:33,012 WARN
[org.keycloak.services] (executor-thread-5) KC-SERVICES0013: Failed
authentication: java.lang.IllegalStateException: Could not find
ScriptEngine for script: Script{id=’null’, realmId=’master’,
name=’role-based-authenticator’, type=’text/javascript’,
code=’AuthenticationFlowError =
Java.type(“org.keycloak.authentication.AuthenticationFlowError”);

But as per release notes at https://www.keycloak.org/docs/latest/release_notes/index.html#keycloak-21-1-0 version 21.1.0 onwards Nashorn javascript engine is available in Keycloak server by default, but for some reason this does not work. How can i fix this?