When converting Keycloak sample authentication provider (Secret question authenticator) from Java
to Kotlin
, the plugin does not work any more. When deploying the Jar
file, log
raises odd errors such as bad signature. As far as I struggled, the problem is Kotlin runtime libraries. Is there a way to fix this?
The problem is that Kotlin has dependencies (Kotlin StdLib or AKA Kotlin runtime). Despite many documents and answers, the solution is not making a (So-called) Fat JAR by famous lines below gradle build script. The right way to resolve dependencies is to add them as WildFly (JBoss) modules using CLI or manual method.
module add --name=org.jetbrains.kotlin --dependencies=org.jetbrains --resources=<path-to-jar-file>
module add --name=org.jetrains --rsources=<path-to-jar-file>
After that, we may add then in a special JBoss file jboss-deployment-structure.xml within META-INF directory:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.jetbrains.kotlin" />
</dependencies>
</deployment>
Now the jar successfully deploys and works!