You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, this is my first post here, but I have been using Quarkus for a while now. A quick background of our app is that we are porting a legacy Java app that is utilizing Hibernate and Spring Framework (with Spring Data JPA) to Quarkus. We have chosen to implement Hibernate ORM with Panache to support REST resources accessed from an Angular front end. Our business model is such that we support customers who can run with any one of a select list of database providers (currently Oracle, PostgreSQL, DB2 and MySQL). As such, we would like to be as efficient and flexible as we can with our build configurations so we can deliver something our customers can easily configure and run.
I run quarkus build, and then utilize the default fast-jar way of running the app locally on my Windows laptop. What is happening, when using the configuration shown above, is that if I set the default config's db-kind property to 'oracle', I can run with either java -jar quarkus-run.jar or java -Dquarkus.profile=oracle -jar quarkus-run.jar and all is good - startup is clean and services are successfully accessing the Oracle db:
However, if I then try running with the Postgres profile using java -Dquarkus.profile=postgres -jar quarkus-run.jar I receive this error:
C:\run-dn2>java -Dquarkus.profile=postgres -jar quarkus-run.jar
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
18:33:32 WARN traceId=, parentId=, spanId=, sampled= [io.ag.pool] (JPA Startup Thread) Datasource '<default>': Driver does not support the provided URL: jdbc:postgresql://xxxxxxxxxx:5432/xxxx
18:33:32 WARN traceId=, parentId=, spanId=, sampled= [io.ag.pool] (agroal-11) Datasource '<default>': Driver does not support the provided URL: jdbc:postgresql://xxxxxxxxxx:5432/xxxx
18:33:32 WARN traceId=, parentId=, spanId=, sampled= [or.hi.en.jd.sp.SqlExceptionHelper] (JPA Startup Thread) SQL Error: 0, SQLState: null
18:33:32 ERROR traceId=, parentId=, spanId=, sampled= [or.hi.en.jd.sp.SqlExceptionHelper] (JPA Startup Thread) Driver does not support the provided URL: jdbc:postgresql://xxxxxxxxxx:5432/xxxx
18:33:32 WARN traceId=, parentId=, spanId=, sampled= [or.hi.en.jd.en.in.JdbcEnvironmentInitiator] (JPA Startup Thread) HHH000342: Could not obtain connection to query metadata: org.hibernate.exception.GenericJDBCException: unable to obtain isolated JDBC connection [Driver does not support the provided URL: jdbc:postgresql://xxxxxxxxxx:5432/xxxx] [n/a]
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:63)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:108)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:94)
at org.hibernate.resource.transaction.backend.jta.internal.JtaIsolationDelegate.doTheWork(JtaIsolationDelegate.java:206)
at org.hibernate.resource.transaction.backend.jta.internal.JtaIsolationDelegate.lambda$delegateWork$3(JtaIsolationDelegate.java:91)
at org.hibernate.resource.transaction.backend.jta.internal.JtaIsolationDelegate.doInSuspendedTransaction(JtaIsolationDelegate.java:125)
at org.hibernate.resource.transaction.backend.jta.internal.JtaIsolationDelegate.delegateWork(JtaIsolationDelegate.java:88)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata(JdbcEnvironmentInitiator.java:320)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:129)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:81)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:130)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:238)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215)
at org.hibernate.service.ServiceRegistry.requireService(ServiceRegistry.java:68)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:52)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:136)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:247)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215)
at org.hibernate.service.ServiceRegistry.requireService(ServiceRegistry.java:68)
at org.hibernate.boot.internal.SessionFactoryOptionsBuilder.<init>(SessionFactoryOptionsBuilder.java:290)
at io.quarkus.hibernate.orm.runtime.recording.PrevalidatedQuarkusMetadata.buildSessionFactoryOptionsBuilder(PrevalidatedQuarkusMetadata.java:72)
at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:84)
at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:72)
at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)
at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:163)
at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:63)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.sql.SQLException: Driver does not support the provided URL: jdbc:postgresql://xxxxxxxxxx:5432/xxxx
at io.agroal.pool.ConnectionFactory.connectionSetup(ConnectionFactory.java:241)
at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:225)
at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:580)
at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:561)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:75)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
... 1 more
I have tried removing the default configuration completely, thinking it is the reason the "non-matching" profile fails to start successfully, but then the build will not even complete - I receive the following build error:
[INFO] --- quarkus-maven-plugin:3.19.4:build (default) @ services ---
[WARNING] [io.quarkus.agroal.deployment.AgroalProcessor] The Agroal dependency is present but no JDBC datasources have been defined.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:24 min
[INFO] Finished at: 2025-03-25T18:51:50-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:3.19.4:build (default) on project services: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR] [error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#configurationDescriptorBuilding threw an exception: io.quarkus.runtime.configuration.ConfigurationException: Unable to find datasource '<default>' for persistence unit '<default>': Datasource '<default>' is not configured. To solve this, configure datasource '<default>'. Refer to https://quarkus.io/guides/datasource for guidance.
[ERROR] at io.quarkus.hibernate.orm.runtime.PersistenceUnitUtil.unableToFindDataSource(PersistenceUnitUtil.java:115)
[ERROR] at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.handleHibernateORMWithNoPersistenceXml(HibernateOrmProcessor.java:885)
[ERROR] at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.configurationDescriptorBuilding(HibernateOrmProcessor.java:350)
[ERROR] at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:732)
[ERROR] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
[ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:255)
[ERROR] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
[ERROR] at java.base/java.lang.Thread.run(Thread.java:842)
[ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:499)
[ERROR] Caused by: io.quarkus.runtime.configuration.ConfigurationException: Datasource '<default>' is not configured. To solve this, configure datasource '<default>'. Refer to https://quarkus.io/guides/datasource for guidance.
[ERROR] at io.quarkus.datasource.common.runtime.DataSourceUtil.dataSourceNotConfigured(DataSourceUtil.java:47)
[ERROR] at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.handleHibernateORMWithNoPersistenceXml(HibernateOrmProcessor.java:886)
[ERROR] ... 11 more
Would anyone have a hint on what configuration I can use to accomplish my goals? Or if I am flat-out doing the wrong thing and there's an easier way? :)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, this is my first post here, but I have been using Quarkus for a while now. A quick background of our app is that we are porting a legacy Java app that is utilizing Hibernate and Spring Framework (with Spring Data JPA) to Quarkus. We have chosen to implement Hibernate ORM with Panache to support REST resources accessed from an Angular front end. Our business model is such that we support customers who can run with any one of a select list of database providers (currently Oracle, PostgreSQL, DB2 and MySQL). As such, we would like to be as efficient and flexible as we can with our build configurations so we can deliver something our customers can easily configure and run.
With that said, and having looked at the example in the datasource configuration guide (https://quarkus.io/guides/datasource#configure-multiple-datasources) as well as the hibernate-orm configuration guide (https://quarkus.io/guides/hibernate-orm#multiple-persistence-units), my goal is to configure our project to support multiple datasources that can be started by using the
-Dquarkus.profile={profile-name}
parameter.Right now, I have it configured with a default configuration (I think) and two profiles - one for Oracle and one for Postgres:
default config
quarkus.datasource.db-kind=oracle
quarkus.datasource.jdbc.url=jdbc:oracle:thin:@xxxxxxxx:1521:xxxxxxx
quarkus.datasource."oracle".active=false
quarkus.datasource."postgres".active=false
.
.
quarkus.hibernate-orm.database.default-schema=xxxxxxxx
quarkus.hibernate-orm."oracle".active=false
quarkus.hibernate-orm."postgres".active=false
quarkus.hibernate-orm.database.generation=none
quarkus.hibernate-orm.log.sql=false
quarkus.hibernate-orm.packages=com.abc.def.model
oracle profile
%oracle.quarkus.datasource.db-kind=oracle
%oracle.quarkus.datasource."oracle".active=true
%oracle.quarkus.datasource.jdbc.url=jdbc:oracle:thin:@xxxxxxxx:1521:xxxxxxx
.
.
%oracle.quarkus.hibernate-orm.database.default-schema=xxxxxxxx
%oracle.quarkus.hibernate-orm."oracle".active=true
%oracle.quarkus.hibernate-orm.database.generation=none
%oracle.quarkus.hibernate-orm.log.sql=false
%oracle.quarkus.hibernate-orm.packages=com.abc.def.model
postgres profile
%postgres.quarkus.datasource.db-kind=postgresql
%postgres.quarkus.datasource."postgres".active=true
%postgres.quarkus.datasource.jdbc.url=jdbc:postgresql://xxxxxxxxxx:5432/xxxx
.
.
%postgres.quarkus.hibernate-orm."postgres".active=true
%postgres.quarkus.hibernate-orm.database.generation=none
%postgres.quarkus.hibernate-orm.log.sql=false
%postgres.quarkus.hibernate-orm.database.default-schema=xxxxxxxx
%postgres.quarkus.hibernate-orm.packages=com.abc.def.model
I run quarkus build, and then utilize the default fast-jar way of running the app locally on my Windows laptop. What is happening, when using the configuration shown above, is that if I set the default config's
db-kind
property to 'oracle', I can run with eitherjava -jar quarkus-run.jar
orjava -Dquarkus.profile=oracle -jar quarkus-run.jar
and all is good - startup is clean and services are successfully accessing the Oracle db:However, if I then try running with the Postgres profile using
java -Dquarkus.profile=postgres -jar quarkus-run.jar
I receive this error:I have tried removing the default configuration completely, thinking it is the reason the "non-matching" profile fails to start successfully, but then the build will not even complete - I receive the following build error:
Would anyone have a hint on what configuration I can use to accomplish my goals? Or if I am flat-out doing the wrong thing and there's an easier way? :)
Beta Was this translation helpful? Give feedback.
All reactions