Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quarkus 3.17: DevServices unavailable in production mode #45065

Open
nicolasduminil opened this issue Dec 11, 2024 · 5 comments
Open

Quarkus 3.17: DevServices unavailable in production mode #45065

nicolasduminil opened this issue Dec 11, 2024 · 5 comments
Labels
area/devservices kind/question Further information is requested

Comments

@nicolasduminil
Copy link

Describe the bug

Hello,

I've read the Migration Guide 3.17 and I'm aware about the modifications that this new release brings concerning the default properties setting.

I'm not using reactive clients, just classical one and need to use DevServices to automatically start, in production mode, a PostgreSQL database. I know that this isn't recommended as DevServices are supposed to be used only in dev or test mode but, in my case, I find using them practical in order to test locally by running java -jar ... command.

I have the following application.properties file:

...
%prod.quarkus.devservices.enabled=true
%prod.quarkus.datasource.devservices.enabled=true
%prod.quarkus.datasource.devservices.port=5432
%prod.quarkus.datasource.devservices.db-name=...
%prod.quarkus.datasource.devservices.username=...
%prod.quarkus.datasource.devservices.password=...
...

I get the following exception:

2024-12-11 15:04:33,824 WARN  [org.hib.eng.jdb.env.int.JdbcEnvironmentInitiator] (JPA Startup Thread) HHH000342: Could not obtain connection to query metadata: org.hibernate.exception.JDBCConnectionException: unable to obtain isolated JDBC connection [Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.] [n/a]

Adding the property:

%prod.quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:${quarkus.datasource.devservices.port}/${quarkus.datasource.devservices.db-name}

to the configuration file raises:

2024-12-11 15:20:06,672 ERROR [org.hib.eng.jdb.spi.SqlExceptionHelper] (JPA Startup Thread) Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Unless I'm mistaken, DevServices were working in production mode prior to 3.17. Am I missing anything here ?

Expected behavior

I expect that, given the defined properties, DevServices work in production mode.

Actual behavior

In production mode, no container is started and the database instance isn't available.

How to Reproduce?

Don't have a reproducer but I can provide one, if it makes sense.

Output of uname -a or ver

Linux nicolas-XPS-15-9570 6.8.0-49-generic #49-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 4 02:06:24 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

java version "21.0.3" 2024-04-16 LTS Java(TM) SE Runtime Environment (build 21.0.3+7-LTS-152) Java HotSpot(TM) 64-Bit Server VM (build 21.0.3+7-LTS-152, mixed mode, sharing)

Quarkus version or git rev

3.17

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546) Maven home: /opt/apache-maven-3.9.5 Java version: 21.0.3, vendor: Oracle Corporation, runtime: /usr/lib/jvm/jdk-21-oracle-x64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "6.8.0-49-generic", arch: "amd64", family: "unix"

Additional information

N/A

@nicolasduminil nicolasduminil added the kind/bug Something isn't working label Dec 11, 2024
Copy link

quarkus-bot bot commented Dec 11, 2024

/cc @geoand (devservices), @stuartwdouglas (devservices)

@geoand geoand added kind/question Further information is requested and removed kind/bug Something isn't working labels Dec 11, 2024
@geoand
Copy link
Contributor

geoand commented Dec 11, 2024

Unless I'm mistaken, DevServices were working in production mode prior to 3.17. Am I missing anything here ?

Not than I am aware of

cc @yrodiere

@yrodiere
Copy link
Member

Hey,

I get the following exception:

2024-12-11 15:04:33,824 WARN  [org.hib.eng.jdb.env.int.JdbcEnvironmentInitiator] (JPA Startup Thread) HHH000342: Could not obtain connection to query metadata: org.hibernate.exception.JDBCConnectionException: unable to obtain isolated JDBC connection [Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.] [n/a]

This just means the DB is not there.

I don't understand how dev services would work when using java -jar because, as far as I know, they are started directly in build steps... ?

Anyway, if you say it used to work, and Georgios agrees...

Don't have a reproducer but I can provide one, if it makes sense.

Please do.

@geoand
Copy link
Contributor

geoand commented Dec 11, 2024

I don't understand how dev services would work when using java -jar because, as far as I know, they are started directly in build steps... ?

The only way dev services can work for prod mode is if you run mvn quarkus:run

@nicolasduminil
Copy link
Author

@yrodiere : my understanding was that properties like %prod.quarkus.datasource.devservices.* were dedicated to configure DevServices in production mode. I could provide a reproducer but if you're saying that it isn't supposed to work, then it isn't worth to, as it requires some work anyway.

@geoand: running with mvn quarkus:run raises the following exception:

[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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devservices kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants