简体   繁体   中英

Unable to configure postgreSQL datasource for Keycloak

I'm trying to configure a PostgresSQL datasource by following the tutorial presented in the documentation: http://www.keycloak.org/docs/1.9/server_installation_guide/topics/database.html . I'm doing the configuration for a standalone server by running standalone.bat and by configuring everything in keycloak-3.0.0.Final/standalone/configuration/standalone.xml .

I'm following the documentation step-by-step, but I get the following error running standalone.bat every-time, and thus I'm unable to connect to the database.

15:33:11,684 ERROR [org.jboss.as.controller.management-operation] 
(Controller Boot Thread) WFLYCTL0013: Operation ("add"
) failed - address: ([
 ("subsystem" => "datasources"),
 ("data-source" => "KeycloakDS")
]) - failure description: {"WFLYCTL0180: Services with 
missing/unavailable dependencies" => [
 "org.wildfly.data-source.KeycloakDS is missing 
[jboss.jdbc-driver.postgres-driver]",
 "jboss.driver-demander.java:jboss/datasources/KeycloakDS is missing 
[jboss.jdbc-driver.postgres-driver]"
]}
15:33:11,687 ERROR [org.jboss.as.controller.management-operation] 
(Controller Boot Thread) WFLYCTL0013: Operation ("add"
) failed - address: ([
 ("subsystem" => "datasources"),
 ("data-source" => "KeycloakDS")
]) - failure description: {"WFLYCTL0180: Services with 
missing/unavailable dependencies" => [
 "org.wildfly.data-source.KeycloakDS is missing 
[jboss.jdbc-driver.postgres-driver]",
 "jboss.driver-demander.java:jboss/datasources/KeycloakDS is missing 
[jboss.jdbc-driver.postgres-driver]",
 "org.wildfly.data-source.KeycloakDS is missing 
[jboss.jdbc-driver.postgres-driver]"

I have tried different versions of JDBC drivers provided by: https://jdbc.postgresql.org/ , but to no avail, even by using the version mentioned in the documentation.

At this point I am stuck since my configuration files look exactly like in the documentation. What exactly could I be missing? Is the documentation up to date?

you cant find the same question- http://lists.jboss.org/pipermail/keycloak-user/2017-March/010120.html , but couldnt find any solution there,so re posting the same here.

I use jboss-cli.sh (or .bat if you're on Windows) to manage this for me. With Keycloak stopped and your PATH including $KEYCLOAK_HOME/bin I put the script below into a file (example: config_db.cli):

embed-server --server-config=standalone.xml --std-out=echo

batch
#
# remove the default provided datasource
#
/subsystem=datasources/data-source=KeycloakDS/:remove

#
# add it back using PostgreSQL
#
module add --name=org.postgres --resources=/path/to/your/postgresql-42.1.4.jar --dependencies=javax.api,javax.transaction.api

/subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgres",driver-class-name=org.postgresql.Driver)

/subsystem=datasources/data-source=KeycloakDS/:add(connection-url=jdbc:postgresql://localhost:5432/db_name,driver-name=postgres,jndi-name=java:jboss/datasources/KeycloakDS,password=db_password,user-name=db_user)

run-batch

And run with bin/jboss-cli.sh --file=config_db.cli

Note that this assumes you've already created a PostgreSQL database user ( db_user above) with a password ( db_password ) and a database owned by the db_user ( db_name ).

In this way I can create my datasources the same way on my local machine as I do on my servers.

CORRECTIONS MADE: The format for running the jboss-cl.sh is: bin/jboss-cli.sh --file=filename

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM