简体   繁体   中英

How to change postgresql database configuration on keycloak-10.0.1

How to connect with postgresql database in keycloak? by-default keycloak is use H2 database but we have to change the database from H2 to postgresql so i request you please help to connect with postgresql database in keycloak.

        1). I have put the postgresql jar and mudule.xml file in below path:-

       D:\Users\itteam\Downloads\keycloak-10.0.1\modules\system\layers\keycloak\org\postgresql

            2). module.xml

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

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

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

            3). standalone.xml

            <datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
                                  ​<connection-url>jdbc:postgresql://localhost:5432/keycloak-dev</connection-url>
                                  ​<driver>postgresql</driver>
                                  ​<pool>
                                      ​<max-pool-size>20</max-pool-size>
                                  ​</pool>
                                  ​<security>
                                      ​<user-name>postgres</user-name>
                                      ​<password>password</password>
                                  ​</security>
                              ​</datasource>
                            <drivers>
                                <driver name="postgresql" module="org.postgresql">
                                     ​<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
                                 ​</driver>
                                <driver name="h2" module="com.h2database.h2">
                                    <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                                </driver>
                            </drivers>
                        </datasources>

     **4). After running standalone.conf.bat file then i am getting the below error logs please help me.**



            *Calling "D:\Users\itteam@tekmindz.com\Downloads\keycloak-10.0.1\bin\standalone.conf.bat"
            Setting JAVA property to "C:\Program Files\Java\jdk1.8.0_251\bin\java"*
            ===============================================================================

              JBoss Bootstrap Environment

              JBOSS_HOME: "D:\Users\itteam@tekmindz.com\Downloads\keycloak-10.0.1 - postgresql"

              JAVA: "C:\Program Files\Java\jdk1.8.0_251\bin\java"

              JAVA_OPTS: "-Dprogram.name=standalone.bat -Xms64M -Xmx512M -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman "

            ===============================================================================

            20:37:15,516 INFO  [org.jboss.modules] (main) JBoss Modules version 1.10.0.Final
            20:37:16,438 INFO  [org.jboss.msc] (main) JBoss MSC version 1.4.11.Final
            20:37:16,454 INFO  [org.jboss.threads] (main) JBoss Threads version 2.3.3.Final
            20:37:16,626 INFO  [org.jboss.as] (MSC service thread 1-1) WFLYSRV0049: Keycloak 10.0.1 (WildFly Core 11.1.1.Final) starting
            20:37:18,688 INFO  [org.wildfly.security] (ServerService Thread Pool -- 20) ELY00001: WildFly Elytron version 1.11.4.Final
            20:37:19,095 INFO  [org.jboss.as.controller] (Controller Boot Thread) OPVDX002: Failed to pretty print validation error: null
            20:37:19,095 ERROR [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0055: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: WFLYCTL0085: Failed to parse configuration
                    at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:143)
                    at org.jboss.as.server.ServerService.boot(ServerService.java:392)
                    at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:416)
                    at java.lang.Thread.run(Thread.java:748)
            Caused by: javax.xml.stream.XMLStreamException: com.ctc.wstx.exc.WstxParsingException: Received non-all-whitespace CHARACTERS or CDATA event in nextTag().
             at [row,col {unknown-source}]: [150,8]
                    at org.jboss.as.connector.subsystems.datasources.DataSourcesExtension$DataSourceSubsystemParser.readElement(DataSourcesExtension.java:650)
                    at org.jboss.as.connector.subsystems.datasources.DataSourcesExtension$DataSourceSubsystemParser.readElement(DataSourcesExtension.java:204)
                    at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:122)
                    at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:69)
                    at org.jboss.as.server.parsing.StandaloneXml_10.parseServerProfile(StandaloneXml_10.java:587)
                    at org.jboss.as.server.parsing.StandaloneXml_10.readServerElement(StandaloneXml_10.java:222)
                    at org.jboss.as.server.parsing.StandaloneXml_10.readElement(StandaloneXml_10.java:119)
                    at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:126)
                    at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:52)
                    at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:122)
                    at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:76)
                    at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:126)
                    ... 3 more
            Caused by: com.ctc.wstx.exc.WstxParsingException: Received non-all-whitespace CHARACTERS or CDATA event in nextTag().
             at [row,col {unknown-source}]: [150,8]
                    at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:634)
                    at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:504)
                    at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:488)
                    at com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1223)
                    at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.nextTag(XMLExtendedStreamReaderImpl.java:152)
                    at org.jboss.as.connector.subsystems.datasources.DsParser.parseDataSource_4_0(DsParser.java:1927)
                    at org.jboss.as.connector.subsystems.datasources.DsParser.parseDataSources(DsParser.java:229)
                    at org.jboss.as.connector.subsystems.datasources.DsParser.parse(DsParser.java:189)
                    at org.jboss.as.connector.subsystems.datasources.DataSourcesExtension$DataSourceSubsystemParser.readElement(DataSourcesExtension.java:643)
                    ... 14 more

            20:37:19,095 FATAL [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0056: Server boot has failed in an unrecoverable manner; exiting. See previous messages for details.
            20:37:19,126 INFO  [org.jboss.as] (MSC service thread 1-1) WFLYSRV0050: Keycloak 10.0.1 (WildFly Core 11.1.1.Final) stopped in 21ms
            Press any key to continue . . .


              [1]: https://i.stack.imgur.com/7FVpn.png

by-default keycloak is use H2 database but we have to change the database from H2 to postgresql so i request you please help to connect with postgresql database in keycloak

I switched my text editor to PyCharm and it showed a few non-visible characters which I deleted and the parsing of the configuration file was successful.

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