3

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?

Valsaraj Viswanathan
  • 1,473
  • 5
  • 28
  • 51

3 Answers3

7

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"/>
Valsaraj Viswanathan
  • 1,473
  • 5
  • 28
  • 51
0

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
fcdt
  • 2,371
  • 5
  • 14
  • 26
0

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>
3ygun
  • 1,192
  • 12
  • 14