keycloak / keycloak-quickstarts

Apache License 2.0
1.99k stars 985 forks source link

user-storage-jpa throwing error "The application must supply JDBC connections" #341

Closed nicolabeghin closed 2 years ago

nicolabeghin commented 2 years ago

Describe the bug

Hi everyone I'm testing the Quarkus-updated user-storage-jpa quickstart in order to subsequently upgrade multiple-ds-user-storage.

When starting the server, the following error is thrown and Quarkus fails to startup.

The application must supply JDBC connections 

Below the full stacktrace:

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.<init>(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:71)
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:138)
at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:54)
at java.base/java.lang.Thread.run(Thread.java:829)

Version

18.0.1

Expected behavior

Keycloak to start up.

Actual behavior

Keycloak unable to start up.

How to Reproduce?

Minimum Reproducible Example repo available at https://github.com/nicolabeghin/keycloak-issue-quarkus-user-storage-jpa

git checkout git@github.com:keycloak/keycloak-quickstarts.git
cd keycloak-quickstarts/user-storage-jpa
mvn package
cp target/user-storage-jpa-example.jar <keycloak>/providers/
docker build -t keycloak_test_image .
docker run --rm -it keycloak_test_image

By removing the user-storage-jpa-example.jar, server starts up fine.

Anything else?

Related issue #303

sluglit commented 2 years ago

@nicolabeghin You seem to be missing the quarkus.properties.file See https://github.com/keycloak/keycloak-quickstarts/tree/main/user-storage-jpa#build-and-deploy-the-quickstart

https://github.com/keycloak/keycloak-quickstarts/blob/main/user-storage-jpa/conf/quarkus.properties

nicolabeghin commented 2 years ago

Thanks @sluglit totally skipped the updated README diff.. I went through line by line in the sourcecode only 😅 THANKS A MILLION!