quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.56k stars 2.62k forks source link

Cannot launch with zero-config postgres devservice database: "configured datasource <default> not found" #23258

Open Felk opened 2 years ago

Felk commented 2 years ago

Quarkus fails to boot with a "zero config setup" for datasources as described in the datasource guide, which states:

If you want to use Dev Services then all you need to do is include the relevant extension for the type of database you want (either reactive or JDBC, or both), and don’t configure a database URL, username and password, Quarkus will provide the database and you can just start coding without worrying about config.

Instead, it asks me to configure the default data source.

reproduce

  1. Go to code.quarkus.io
  2. Select hibernate ORM and JDBC-PostgreSQL
  3. download the project and try to run it with mvn quarkus:dev

Quarkus fails to boot with the following error:

2022-01-28 11:22:33,136 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (Aesh InputStream Reader) Failed to start quarkus: java.lang.RuntimeException: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.dev.appstate.ApplicationStateNotification.waitForApplicationStart(ApplicationStateNotification.java:51)
        [...]
        ... 1 more
Caused by: java.lang.RuntimeException: io.quarkus.runtime.configuration.ConfigurationException: Model classes are defined for the default persistence unit <default> but configured datasource <default> not found: the default EntityManagerFactory will not be created. To solve this, configure the default datasource. Refer to https://quarkus.io/guides/datasource for guidance.
        at io.quarkus.hibernate.orm.runtime.JPAConfig.startAll(JPAConfig.java:72)
        [...]

environment

quarkus 2.6.3
windows, with docker in WSL2 Ubuntu 20.04
OpenJDK Temurin-17.0.1+12
maven 3.8.2

Sanne commented 2 years ago

It's assuming that you have docker or podman installed and ready to use: a PosgreSQL container instance will be started and configured automatically.

But if you don't have a container engine, then it will require you to configure a datasource explicitly.

I'll keep the bug open as I agree either the documentation should be clarified, or at least the error message should make this more intuitive.

gilvansfilho commented 2 years ago

@Felk I faced this and the problem is you need docker running on your windows, not on your wsl2 distro.

@Sanne could I update the docs including a warning about this (container engine ready to use)?

Sanne commented 2 years ago

@gilvansfilho yes that would be really nice. Thanks!

So was that the problem in your case? TBH not many of us run Windows so we might not have known of this difference between running docker in windows or in wsl2

cc/ @maxandersen

Felk commented 2 years ago

@Felk I faced this and the problem is you need docker running on your windows, not on your wsl2 distro.

Oh, that is good to know, thank you! I switched from Docker Desktop to docker-ce in WSL2 due to Docker Desktop's licensing changes, so there's no going back for me.

My solution was to also run mvn quarkus:dev within WSL2, not on the Windows host machine. It then works as expected, very nice!

gilvansfilho commented 2 years ago

So was that the problem in your case? TBH not many of us run Windows so we might not have known of this difference between running docker in windows or in wsl2

Perhaps something in my environment? I really dont know but I faced this sometime ago when I tried to run some quickstarts.

gilvansfilho commented 2 years ago

@Sanne I was reasoning about and what happens is when using docker inside WSL2 you need to run your code inside your wsl2 distro terminal not on windows terminal (which doesn't have docker cli).

If you use docker desktop you will have docker cli on your windows so you could run your code directly on your windows terminal.

Is something like trying to do a "ls" in a openshift pod without a prior "oc rsh". The command will run on your enviroment not on pod environment.

@Felk make sure you are trying to run your code on wls2 distro terminal.

gilvansfilho commented 2 years ago

Sorry @Felk I hadn't seen this before the last reply.

My solution was to also run mvn quarkus:dev within WSL2, not on the Windows host machine. It then works as expected, very nice!