Getting error while deploying java application with keycloak in wildfly server.
Caused by: java.lang.IllegalStateException: Not able to load any cryptoProvider with the classLoader: ModuleClassLoader for Module “org.keycloak.keycloak-adapter-core” version 19.0.3 from local module loader @dc9876b (finder: local module finder @2f666ebb (roots: /opt/wildfly/wildfly-16.0.0.Final/modules,/opt/wildfly/wildfly-16.0.0.Final/modules/system/layers/base,/opt/wildfly/wildfly-16.0.0.Final/modules/system/add-ons/keycloak))
Which provides a required default CryptoIntegration implementation DefaultCryptoProvider.
I was runing into some classloading issue because of using the keycloak adapter in an OSGi environment:
Caused by: java.lang.IllegalStateException:
Not able to load any cryptoProvider with the classLoader: org.eclipse.osgi.internal.loader.EquinoxClassLoader@1cf3efe1[org.keycloak.keycloak-adapter-core:21.0.1(id=184)]
at org.keycloak.common.crypto.CryptoIntegration.detectProvider(CryptoIntegration.java:59)
at org.keycloak.common.crypto.CryptoIntegration.init(CryptoIntegration.java:32)
at org.keycloak.adapters.KeycloakDeploymentBuilder.build(KeycloakDeploymentBuilder.java:204)
....
Sadly the new keycloak-crypto-default is no OSGi bundle hence I had to create one with the jar
Before initializing the KeycloakDeyploymentBuilder I execute the following code to force initialization in the classloader context of my bundle (which imports the keycloak-crypto-default OSGi bundle):