depoly user-storage-jpa keycloak quike start?

189 views Asked by At

recently I am trying to implement a custom user storage provider for keycloak in order to integrate keycloak with external database, therefore I cloned the keycloak quick start and used the user-storage-jpa, first of all I copied the conf/quarkus.propeties file to the conf directory of keycloak distribution with the initial properties like this

quarkus.datasource.user-store.db-kind=h2
quarkus.datasource.user-store.username=sa
quarkus.datasource.user-store.jdbc.url=jdbc:postgres:mem:user-store;DB_CLOSE_DELAY=-1

, then apply "mvn clean install " to generate the jar file , after that copied the jar to provider directory, and start the keycloak using " sh kc.sh start-dev", and here where I gt the following error:

2023-05-21 13:40:04,283 INFO [org.keycloak.quarkus.runtime.hostname.DefaultHostnameProvider] (main) Hostname settings: Base URL: , Hostname: , Strict HTTPS: false, Path: , Strict BackChannel: false, Admin URL: , Admin: , Port: -1, Proxied: false 2023-05-21 13:40:08,196 WARN [io.quarkus.agroal.runtime.DataSources] (main) Datasource enables XA but transaction recovery is not enabled. Please enable transaction recovery by setting quarkus.transaction-manager.enable-recovery=true, otherwise data may be lost if the application is terminated abruptly 2023-05-21 13:40:08,632 WARN [org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator] (JPA Startup Thread: user-store) HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections 2023-05-21 13:40:08,637 WARN [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator] (JPA Startup Thread: user-store) HHH000342: Could not obtain connection to query metadata: java.lang.UnsupportedOperationException: The application must supply JDBC connections at org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl.getConnection(UserSuppliedConnectionProviderImpl.java:44) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:181) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:107) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:246) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) at org.hibernate.boot.internal.SessionFactoryOptionsBuilder.(SessionFactoryOptionsBuilder.java:272) at io.quarkus.hibernate.orm.runtime.recording.PrevalidatedQuarkusMetadata.buildSessionFactoryOptionsBuilder(PrevalidatedQuarkusMetadata.java:68) at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:72) at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:72) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:80) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55) at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:165) at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:66) at java.base/java.lang.Thread.run(Thread.java:829)

2023-05-21 13:40:12,214 INFO [org.infinispan.SERVER] (keycloak-cache-init) ISPN005054: Native IOUring transport not available, using NIO instead: io.netty.incubator.channel.uring.IOUring 2023-05-21 13:40:12,407 WARN [org.infinispan.PERSISTENCE] (keycloak-cache-init) ISPN000554: jboss-marshalling is deprecated and planned for removal 2023-05-21 13:40:12,490 WARN [org.infinispan.CONFIG] (keycloak-cache-init) ISPN000569: Unable to persist Infinispan internal caches as no global state enabled 2023-05-21 13:40:12,585 INFO [org.infinispan.CONTAINER] (keycloak-cache-init) ISPN000556: Starting user marshaller 'org.infinispan.jboss.marshalling.core.JBossUserMarshaller' 2023-05-21 13:40:13,562 INFO [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000088: Unable to use any JGroups configuration mechanisms provided in properties {}. Using default JGroups configuration! 2023-05-21 13:40:13,888 INFO [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000078: Starting JGroups channel ISPN 2023-05-21 13:40:13,948 INFO [org.jgroups.JChannel] (keycloak-cache-init) local_addr: c484dc46-4679-4ad0-bb51-9d4b0fc4131b, name: kaisios-Inspiron-3521-32921 2023-05-21 13:40:13,956 WARN [org.jgroups.protocols.UDP] (keycloak-cache-init) JGRP000015: the send buffer of socket MulticastSocket was set to 1MB, but the OS only allocated 212.99KB 2023-05-21 13:40:13,957 WARN [org.jgroups.protocols.UDP] (keycloak-cache-init) JGRP000015: the receive buffer of socket MulticastSocket was set to 20MB, but the OS only allocated 212.99KB 2023-05-21 13:40:13,958 WARN [org.jgroups.protocols.UDP] (keycloak-cache-init) JGRP000015: the send buffer of socket MulticastSocket was set to 1MB, but the OS only allocated 212.99KB 2023-05-21 13:40:13,959 WARN [org.jgroups.protocols.UDP] (keycloak-cache-init) JGRP000015: the receive buffer of socket MulticastSocket was set to 25MB, but the OS only allocated 212.99KB 2023-05-21 13:40:13,978 INFO [org.jgroups.protocols.FD_SOCK2] (keycloak-cache-init) server listening on *.37035 2023-05-21 13:40:15,992 INFO [org.jgroups.protocols.pbcast.GMS] (keycloak-cache-init) kaisios-Inspiron-3521-32921: no members discovered after 2010 ms: creating cluster as coordinator 2023-05-21 13:40:16,040 INFO [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000094: Received new cluster view for channel ISPN: [kaisios-Inspiron-3521-32921|0] (1) [kaisios-Inspiron-3521-32921] 2023-05-21 13:40:16,073 INFO [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000079: Channel ISPN local address is kaisios-Inspiron-3521-32921, physical addresses are [172.22.0.1:52571] 2023-05-21 13:40:17,316 INFO [org.infinispan.CLUSTER] (main) ISPN000080: Disconnecting JGroups channel ISPN ERROR: Failed to start server in (development) mode ERROR: javax.persistence.PersistenceException: [PersistenceUnit: user-store] Unable to build Hibernate SessionFactory ERROR: [PersistenceUnit: user-store] Unable to build Hibernate SessionFactory ERROR: The application must supply JDBC connections For more details run the same command passing the '--verbose' option. Also you can use '--help' to see the details about the usage of the particular command.

therefore I changed the propertes to use a postgres database with the following prop:

quarkus.datasource.user-store.db-kind=postgres
quarkus.datasource.user-store.username=test
quarkus.datasource.user-store.password=test
quarkus.datasource.user-store.jdbc.url=jdbc:postgres:mem:user-store;DB_CLOSE_DELAY=-1

unfortunately, the same error has raised, any help of what I am missing ... thanks in advance.

0

There are 0 answers