无法将 postgres 与 keycloak 一起使用 [英] Unable to use postgres with keycloak

查看:40
本文介绍了无法将 postgres 与 keycloak 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 postgres 与 keycloak 一起使用.关注 Doc

I am trying to use postgres with keycloak. following Doc

$ ls keycloak-9.0.0/modules/system/layers/keycloak/org/postgresql/main
  config.xml  postgresql-42.2.10.jar

这是 config.xml 文件.config.xml

This is the config.xml file. config.xml

<?xml version="1.0" ?>
<module xmlns="urn:jboss:module:1.3" name="org.postgresql">

    <resources>
        <resource-root path="postgresql-42.2.10.jar"/>
    </resources>

    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

这些是我在 standalone.xml 中所做的更改standalone.xml

These are the changes that i have made in standalone.xml standalone.xml

<datasources>

    <datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
      <connection-url>jdbc:postgresql://localhost:5432/test</connection-url>
      <driver>postgresql</driver>
      <pool>
           <max-pool-size>20</max-pool-size>
      </pool>
      <security>
           <user-name>postgres</user-name>
           <password>StrongPassword</password>
      </security>
   </datasource>

    <drivers>
         <driver name="postgresql" module="org.postgresql">
              <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
          </driver>
     </drivers>


</datasources>

<default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasources/KeycloakDS">

我得到的错误.错误

06:13:39,430 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 32) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("jdbc-driver" => "postgresql")
]) - failure description: "WFLYJCA0115: Module for driver [org.postgresql] or one of it dependencies is missing: [org.postgresql]"

我该如何解决这个问题?

How can i resolve this?

推荐答案

我能否提出另一种不太可能出现问题的配置方法?我使用以下配置 PostgreSQL 和 Keycloak,它一直运行良好.关键是针对停止的 Keycloak 运行它(使用全新安装).将以下内容保存到类似 setup-keycloak.cli 的文件中:

Can I suggest another way to configure this that is less likely to have an issue? I use the following to configure PostgreSQL and Keycloak and it has been working well. The key is to run this against a stopped Keycloak (using a fresh install). Save the below to something like setup-keycloak.cli:

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

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

#
# add them
#
module add --name=org.postgres --resources=/path/to/postgresql-42.2.10.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/keycloak_database,driver-name=postgres,jndi-name=java:jboss/datasources/KeycloakDS,initial-pool-size=4,max-pool-size=64,min-pool-size=4,password=keycloak_user,user-name=keycloak_pass)

run-batch

然后用 $KEYCLOAK_HOME/bin/jboss.sh --file=setup-keycloak.cli 运行它.这将删除 KeycloakDS 数据源,添加 PostgreSQL 模块,并使用您的参数重新创建 KeycloakDS 数据源.只要您拥有 PostgreSQL JDBC 驱动程序的本地副本,您就可以随时使用它来重现配置.

Then run this with $KEYCLOAK_HOME/bin/jboss.sh --file=setup-keycloak.cli. This removes the KeycloakDS datasource, adds the PostgreSQL module, and recreates the KeycloakDS datasource with your parameters. You can use this to reproduce the configuration any time as long as you have a local copy of the PostgreSQL JDBC driver.

这篇关于无法将 postgres 与 keycloak 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆