[keycloak-user] Exception loading Keycloak modules in Wildfly 9.0

Marko Strukelj mstrukel at redhat.com
Fri Oct 23 10:33:13 EDT 2015


Checking the documentation for our examples I realise it needs a lot of
improvement, and it's especially out of date for the demo :/

So here are the full command line instructions that work for me. If you're
on windows you'll have to translate some of these commands into CLI /
PowerShell.

Since you are only trying to install adapter I assume you want to run
Keycloak server separately from your content server, but the demo works
out-of-the box only when server and protected content are deployed in the
same Wildfly instance. The instructions here configure server part
separately from the client part, but within the same Wildfly instance.

So here we go ...

Download Wildfly 9.0.1, Keycloak Server, Keycloak Wildfly 9 Adapter, and
Keycloak Examples. Use Google to find the Download pages ...

mkdir keycloak
cd keycloak
unzip ~/Downloads/wildfly-9.0.1.Final.zip
cd wildfly-9.0.1.Final

unzip ~/Downloads/keycloak-overlay-1.6.0.Final.zip
unzip ~/Downloads/keycloak-wf9-adapter-dist-1.6.0.Final.zip

(press 'A' for All when ask if you want to overwrite existing files -
adapter and server overlay contain some of the same modules, since each has
to be fully functional by itself)


Now we should open and edit standalone/configuration/standalone.xml to
configure the server (and adapter) part, but we can also configure it
directly through shell using jboss-cli tool:

bin/jboss-cli.sh

embed-server
/subsystem=datasources/data-source=KeycloakDS/:add(connection-url="jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE",driver-name=h2,jndi-name=java:jboss/datasources/KeycloakDS,password=sa,user-name=sa,use-java-context=true)
/subsystem=infinispan/cache-container=keycloak:add(jndi-name="infinispan/Keycloak")
/subsystem=infinispan/cache-container=keycloak/local-cache=realms:add()
/subsystem=infinispan/cache-container=keycloak/local-cache=users:add()
/subsystem=infinispan/cache-container=keycloak/local-cache=sessions:add()
/subsystem=infinispan/cache-container=keycloak/local-cache=loginFailures:add()
/extension=org.keycloak.keycloak-server-subsystem/:add(module=org.keycloak.keycloak-server-subsystem)
/subsystem=keycloak-server:add(web-context=auth)
quit


The configuration changes will be saved to standalone.xml file.


We can do the same in order to configure the adapter part:

bin/jboss-cli.sh

embed-server
/extension=org.keycloak.keycloak-adapter-subsystem/:add(module=org.keycloak.keycloak-adapter-subsystem)
/subsystem=keycloak:add()
quit


Again the changes will be saved to standalone.xml file.


Keycloak is now ready to run, but let's build, and deploy the demo, so that
when we run Wildfly everything will be set up already.


Unpack, and build the demo:

cd ..

unzip ~/Downloads/keycloak-examples-1.6.0.Final.zip
cd keycloak-examples-1.6.0.Final/
cd preconfigured-demo/
mvn clean install


Deploy by copying to deployments dir:

cp database-service/target/database.war
../../wildfly-9.0.1.Final/standalone/deployments/
cp customer-app/target/customer-portal.war
../../wildfly-9.0.1.Final/standalone/deployments/
cp product-app/target/product-portal.war
../../wildfly-9.0.1.Final/standalone/deployments/


We also need to load into Keycloak server the demo realm that contains
roles, users, and application clients for our demo to work. We can do this
while starting up Keycloak server.

cd ../..

cd wildfly-9.0.1.Final

bin/standalone.sh -Dkeycloak.migration.action=import
-Dkeycloak.migration.provider=singleFile
-Dkeycloak.migration.realmName=demo
-Dkeycloak.migration.file=../keycloak-examples-1.6.0.Final/preconfigured-demo/testrealm.json


Next time you start up Wildfly only use:

bin/standalone.sh


Otherwise you'll get an exception during startup notifying you that the
'demo' realm can't be imported, as it already exists!


Your Wildfly running Keycloak server, and the content apps (our demo,
composed of customer-portal.war, product-portal.war, and database.war) is
now ready for use. You can go to:

http://localhost:8080/customer-portal

and click around. When prompted for login, use 'bburke at redhat.com' as a
username, and 'password' as a password.

Let me know if these instructions still don't work for you.

- marko

On Thu, Oct 22, 2015 at 9:51 PM, Vijay Bhadriraju <vbhadrir at us.ibm.com>
wrote:

> Thanks, Marco. I was able to move forward by using the latest adapter you
> pointed me to. I was able to bring up the Wildfly 9.0 server with the
> adapter installed and was able to install the Customer-Portal and
> Product-Portal example apps successfully. But, when I install the Database
> example app, I get the following error. Any tips on how to resolve this
> error ? Thanks.
>
> 15:39:28,922 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5)
> MSC000001: Failed
>  to start service jboss.deployment.unit.database.POST_MODULE:
> org.jboss.msc.service.StartE
> xception in service jboss.deployment.unit.database.POST_MODULE:
> WFLYSRV0153: Failed to pro
> cess phase POST_MODULE of deployment "database"
>         at
> org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitP
> haseService.java:163)
>         at
> org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceContr
> ollerImpl.java:1948)
>         at
> org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl
> .java:1881)
>         at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown
> Source)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
> Source)
>         at java.lang.Thread.run(Unknown Source)
> Caused by:
> org.jboss.as.server.deployment.DeploymentUnitProcessingException:
> WFLYRS0006: C
> ould not load JAX-RS Application class
>         at
> org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scan(JaxrsScanningProcesso
> r.java:205)
>         at
> org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.deploy(JaxrsScanningProces
> sor.java:101)
>         at
> org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitP
> haseService.java:156)
>         ... 5 more
> Caused by: java.lang.ClassNotFoundException:
> org.keycloak.example.oauth.DataApplication fr
> om [Module "deployment.database:main" from Service Module Loader]
>         at
> org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)
>         at
> org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentCla
> ssLoader.java:455)
>         at
> org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClass
> Loader.java:404)
>         at
> org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.
> java:385)
>         at
> org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:13
> 0)
>         at
> org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scan(JaxrsScanningProcesso
> r.java:201)
>         ... 7 more
>
> 15:39:28,937 ERROR [org.jboss.as.controller.management-operation]
> (management-handler-thre
> ad - 5) WFLYCTL0013: Operation ("add") failed - address: ({"deployment" =>
> "database"}) -
> failure description: {"WFLYCTL0080: Failed services" =>
> {"jboss.deployment.unit.database.P
> OST_MODULE" => "org.jboss.msc.service.StartException in service
> jboss.deployment.unit.data
> base.POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of
> deployment \"databas
> e\"
>     Caused by:
> org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYRS000
> 6: Could not load JAX-RS Application class
>     Caused by: java.lang.ClassNotFoundException:
> org.keycloak.example.oauth.DataApplicatio
> n from [Module \"deployment.database:main\" from Service Module Loader]"}}
> 15:39:28,953 ERROR [org.jboss.as.server] (management-handler-thread - 5)
> WFLYSRV0021: Depl
> oy of deployment "database" was rolled back with the following failure
> message:
> {"WFLYCTL0080: Failed services" =>
> {"jboss.deployment.unit.database.POST_MODULE" => "org.j
> boss.msc.service.StartException in service
> jboss.deployment.unit.database.POST_MODULE: WFL
> YSRV0153: Failed to process phase POST_MODULE of deployment \"database\"
>     Caused by:
> org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYRS000
> 6: Could not load JAX-RS Application class
>     Caused by: java.lang.ClassNotFoundException:
> org.keycloak.example.oauth.DataApplicatio
> n from [Module \"deployment.database:main\" from Service Module Loader]"}}
> 15:39:28,953 INFO  [org.jboss.as.server.deployment] (MSC service thread
> 1-1) WFLYSRV0028:
> Stopped deployment database (runtime-name: database) in 11ms
> 15:39:28,953 INFO  [org.jboss.as.controller] (management-handler-thread -
> 5) WFLYCTL0183:
> Service status report
> WFLYCTL0186:   Services which failed to start:      service
> jboss.deployment.unit.database
> .POST_MODULE
>
> Regards, Vijay
>
>
>
>
> From:        Marko Strukelj <mstrukel at redhat.com>
> To:        Vijay Bhadriraju/Raleigh/IBM at IBMUS
> Cc:        keycloak-user <keycloak-user at lists.jboss.org>
> Date:        10/22/2015 12:47 PM
> Subject:        Re: [keycloak-user] Exception loading Keycloak modules in
> Wildfly 9.0
> ------------------------------
>
>
>
> Use the latest keycloak-wf9-adapter-dist from the download site:
> *http://keycloak.jboss.org/keycloak/downloads.html?dir=0%3Dadapters/keycloak-oidc%3B*
> <http://keycloak.jboss.org/keycloak/downloads.html?dir=0%3Dadapters/keycloak-oidc%3B>
>
> You're trying to use latest config syntax with an old version that uses a
> different kind of config, and is outdated.
>
> On Thu, Oct 22, 2015 at 6:02 PM, Vijay Bhadriraju <*vbhadrir at us.ibm.com*
> <vbhadrir at us.ibm.com>> wrote:
> I am getting the following exception after unzipping the
> keycloak-wildfly-adapter-dist-1.1.0.Final.zip into the WildFly 9.0 server
> and configuring the standalone.xml file with the following lines as
> described in the keycloak documentation. I have tried this with Wildfly
> 10.0 version also and get the same error.
>
> <server xmlns="urn:jboss:domain:1.4">
> <extensions>
> *<extension module="org.keycloak.keycloak-adapter-subsystem"/>*
> ...
> </extensions>
> <profile>
> *<subsystem xmlns="urn:jboss:domain:keycloak:1.1"/>*
> ...
> </profile>
>
> How do I resolve this keycloak module loading exception?
>
>
> 11:35:36,018 ERROR [org.jboss.as.server] (Controller Boot Thread)
> WFLYSRV0055: Caught exce
> ption during boot:
> org.jboss.as.controller.persistence.ConfigurationPersistenceException:
> WFLYCTL0085: Failed to parse configuration
>         at
> org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigura
> tionPersister.java:131) [wildfly-controller-2.0.0.CR7.jar:2.0.0.CR7]
>         at org.jboss.as.server.ServerService.boot(ServerService.java:356)
> [wildfly-server-
> 2.0.0.CR7.jar:2.0.0.CR7]
>         at
> org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerServi
> ce.java:299) [wildfly-controller-2.0.0.CR7.jar:2.0.0.CR7]
>         at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_65]
> Caused by: javax.xml.stream.XMLStreamException: WFLYCTL0083: Failed to
> load module org.key
> cloak.keycloak-adapter-subsystem
>         at
> org.jboss.as.controller.parsing.ExtensionXml.parseExtensions(ExtensionXml.java:
> 155) [wildfly-controller-2.0.0.CR7.jar:2.0.0.CR7]
>         at
> org.jboss.as.server.parsing.StandaloneXml_4.readServerElement(StandaloneXml_4.j
> ava:220) [wildfly-server-2.0.0.CR7.jar:2.0.0.CR7]
>         at
> org.jboss.as.server.parsing.StandaloneXml_4.readElement(StandaloneXml_4.java:14
> 3) [wildfly-server-2.0.0.CR7.jar:2.0.0.CR7]
>         at
> org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:69)
> [w
> ildfly-server-2.0.0.CR7.jar:2.0.0.CR7]
>         at
> org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:47)
> [w
> ildfly-server-2.0.0.CR7.jar:2.0.0.CR7]
>         at
> org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)
> [staxm
> apper-1.2.0.Final.jar:1.2.0.Final]
>         at
> org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69)
> [staxma
> pper-1.2.0.Final.jar:1.2.0.Final]
>         at
> org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigura
> tionPersister.java:123) [wildfly-controller-2.0.0.CR7.jar:2.0.0.CR7]
>         ... 3 more
> Caused by: java.util.concurrent.ExecutionException:
> javax.xml.stream.XMLStreamException: W
> FLYCTL0083: Failed to load module
>         at java.util.concurrent.FutureTask.report(Unknown Source)
> [rt.jar:1.8.0_65]
>         at java.util.concurrent.FutureTask.get(Unknown Source)
> [rt.jar:1.8.0_65]
>         at
> org.jboss.as.controller.parsing.ExtensionXml.parseExtensions(ExtensionXml.java:
> 147) [wildfly-controller-2.0.0.CR7.jar:2.0.0.CR7]
>         ... 10 more
> Caused by: javax.xml.stream.XMLStreamException: WFLYCTL0083: Failed to
> load module
>         at
> org.jboss.as.controller.parsing.ExtensionXml.loadModule(ExtensionXml.java:196)
> [wildfly-controller-2.0.0.CR7.jar:2.0.0.CR7]
>         at
> org.jboss.as.controller.parsing.ExtensionXml.access$000(ExtensionXml.java:69)
> [
> wildfly-controller-2.0.0.CR7.jar:2.0.0.CR7]
>         at
> org.jboss.as.controller.parsing.ExtensionXml$1.call(ExtensionXml.java:127)
> [wil
> dfly-controller-2.0.0.CR7.jar:2.0.0.CR7]
>         at
> org.jboss.as.controller.parsing.ExtensionXml$1.call(ExtensionXml.java:124)
> [wil
> dfly-controller-2.0.0.CR7.jar:2.0.0.CR7]
>         at java.util.concurrent.FutureTask.run(Unknown Source)
> [rt.jar:1.8.0_65]
>         at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown
> Source) [rt.jar:1.8.0
> _65]
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
> Source) [rt.jar:1.8.
> 0_65]
>         at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_65]
>         at org.jboss.threads.JBossThread.run(JBossThread.java:320) [
> *jboss-threads-2.2.1.Fi* <http://jboss-threads-2.2.1.fi/>
> nal.jar:2.2.1.Final]
> Caused by: org.jboss.modules.ModuleNotFoundException:
> org.keycloak.keycloak-adapter-subsys
> tem:main
>         at
> org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:236)
> [jboss-modules
> .jar:1.4.4.Final]
>         at
> org.jboss.as.controller.parsing.ExtensionXml.loadModule(ExtensionXml.java:178)
> [wildfly-controller-2.0.0.CR7.jar:2.0.0.CR7]
>         ... 8 more
>
> Regards, Vijay
>
>
> _______________________________________________
> keycloak-user mailing list
> *keycloak-user at lists.jboss.org* <keycloak-user at lists.jboss.org>
> *https://lists.jboss.org/mailman/listinfo/keycloak-user*
> <https://lists.jboss.org/mailman/listinfo/keycloak-user>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20151023/94f1ffc6/attachment-0001.html 


More information about the keycloak-user mailing list