'NoClassDefFoundError: org/keycloak/KeycloakPrincipal
I am getting following exception while deploying ear in WildFly 10. Apapter is installed so no jars included in ear & no dependencies set.
Caused by: java.lang.NoClassDefFoundError: org/keycloak/KeycloakPrincipal Caused by: java.lang.ClassNotFoundException: org.keycloak.KeycloakPrincipal from [Module \"deployment.app.ear.appEJB.jar:main\" from Service Module Loader]"}, "WFLYCTL0412: Required services that are not installed:" => [ "jboss.undertow.deployment.default-server.default-host./App" ]
This issue comes only for classes in appEJB.jar. The classes in appWEB.war has no dependency issue. Here is my subsystem conf:
<subsystem xmlns="urn:jboss:domain:keycloak:1.1">
<secure-deployment name="appWEB.war">
<realm>demo</realm>
<resource>app</resource>
<use-resource-role-mappings>true</use-resource-role-mappings>
<public-client>true</public-client>
<auth-server-url>http://localhost:8180/auth</auth-server-url>
<ssl-required>EXTERNAL</ssl-required>
<principal-attribute>preferred_username</principal-attribute>
</secure-deployment>
</subsystem>
Is there any other way to configure ear deployment in subsystem so that ejb.jar also get Keycloak libraries implicitly?
Solution 1:[1]
Issue fixed when I set Keycloak modules dependency for ejb.jar in jboss deployment descriptor.
<module name="org.keycloak.keycloak-adapter-spi"/>
<module name="org.keycloak.keycloak-adapter-core"/>
<module name="org.keycloak.keycloak-common"/>
<module name="org.keycloak.keycloak-core"/>
Solution 2:[2]
Create MANIFEST.MF in the META-INF path for the ejb.jar project. Write in the file content:
Manifest-Version: 1.0
Dependencies: org.keycloak.keycloak-adapter-spi, org.keycloak.keycloak-adapter-core, org.keycloak.keycloak-common, org.keycloak.keycloak-core
Solution 3:[3]
I had the same error type developing an Authenticator for 16.1.0 the specific error being:
Caused by: java.lang.ClassNotFoundException: org.keycloak.services.util.CookieHelper from [Module "deployment.my-authenticator-1.0-SNAPSHOT.jar" from Service Module Loader]
The solution was @valsaraj-viswanathan answer. However, I wanted to expand on how to set that.
In myAuthenticator/src/main/resources/META-INF/jboss-deployment-structure.xml I added the following content:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module
name="org.keycloak.keycloak-core"
export="true" />
<module
name="org.keycloak.keycloak-server-spi"
export="true" />
<module
name="org.keycloak.keycloak-server-spi-private"
export="true" />
<module
name="org.keycloak.keycloak-services"
export="true" />
</dependencies>
</deployment>
</jboss-deployment-structure>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Valsaraj Viswanathan |
| Solution 2 | fcdt |
| Solution 3 | 3ygun |
