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

Liquibase fails to find datasource when devservices is disabled. #16210

Closed
mincel opened this issue Apr 2, 2021 · 8 comments · Fixed by #16282
Closed

Liquibase fails to find datasource when devservices is disabled. #16210

mincel opened this issue Apr 2, 2021 · 8 comments · Fixed by #16282
Labels
area/liquibase kind/bug Something isn't working
Milestone

Comments

@mincel
Copy link

mincel commented Apr 2, 2021

Describe the bug

I get the following error when I set quarkus.datasource.devservices=false in dev mode after upgrading Quarkus from 1.12.2.Final to 1.13.0.Final. I already have a database running on my dev environment so I don't need another database.

17:24:14 ERROR [io.quarkus.runtime.Application] (Quarkus Main Thread) [] Failed to start application (with profile dev): javax.enterprise.inject.UnsatisfiedResolutionException: No datasource has been configured
	at io.quarkus.liquibase.runtime.LiquibaseRecorder$1.get(LiquibaseRecorder.java:27)
	at io.quarkus.liquibase.runtime.LiquibaseRecorder$1.get(LiquibaseRecorder.java:24)
	at io.quarkus.liquibase.LiquibaseFactory_aaeeb0753d75aedb9e43338fbff15184711093e6_Synthetic_Bean.create(LiquibaseFactory_aaeeb0753d75aedb9e43338fbff15184711093e6_Synthetic_Bean.zig:160)
	at io.quarkus.liquibase.LiquibaseFactory_aaeeb0753d75aedb9e43338fbff15184711093e6_Synthetic_Bean.create(LiquibaseFactory_aaeeb0753d75aedb9e43338fbff15184711093e6_Synthetic_Bean.zig:176)
	at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:96)
	at io.quarkus.arc.impl.AbstractSharedContext.access$000(AbstractSharedContext.java:14)
	at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:29)
	at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:26)
	at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
	at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
	at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:26)
	at io.quarkus.arc.impl.ClientProxies.getApplicationScopedDelegate(ClientProxies.java:17)
	at io.quarkus.liquibase.LiquibaseFactory_aaeeb0753d75aedb9e43338fbff15184711093e6_Synthetic_ClientProxy.arc$delegate(LiquibaseFactory_aaeeb0753d75aedb9e43338fbff15184711093e6_Synthetic_ClientProxy.zig:67)
	at io.quarkus.liquibase.LiquibaseFactory_aaeeb0753d75aedb9e43338fbff15184711093e6_Synthetic_ClientProxy.getDataSourceName(LiquibaseFactory_aaeeb0753d75aedb9e43338fbff15184711093e6_Synthetic_ClientProxy.zig:211)
	at io.quarkus.liquibase.runtime.devconsole.LiquibaseFactoriesSupplier$LiquibaseFactoryComparator.compare(LiquibaseFactoriesSupplier.java:41)
	at io.quarkus.liquibase.runtime.devconsole.LiquibaseFactoriesSupplier$LiquibaseFactoryComparator.compare(LiquibaseFactoriesSupplier.java:35)
	at java.base/java.util.TreeMap.put(TreeMap.java:550)
	at java.base/java.util.TreeSet.add(TreeSet.java:255)
	at io.quarkus.liquibase.runtime.devconsole.LiquibaseFactoriesSupplier.get(LiquibaseFactoriesSupplier.java:30)
	at io.quarkus.liquibase.runtime.devconsole.LiquibaseFactoriesSupplier.get(LiquibaseFactoriesSupplier.java:18)
	at io.quarkus.vertx.http.runtime.devmode.DevConsoleRecorder.addInfo(DevConsoleRecorder.java:37)
	at io.quarkus.deployment.steps.DevConsoleProcessor$runtimeTemplates-308161071.deploy_0(DevConsoleProcessor$runtimeTemplates-308161071.zig:150)
	at io.quarkus.deployment.steps.DevConsoleProcessor$runtimeTemplates-308161071.deploy(DevConsoleProcessor$runtimeTemplates-308161071.zig:40)
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:1058)
	at io.quarkus.runtime.Application.start(Application.java:90)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:100)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:119)
	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.quarkus.runner.bootstrap.StartupActionImpl$3.run(StartupActionImpl.java:134)
	at java.base/java.lang.Thread.run(Thread.java:834)

Expected behavior

I expect Liquibase to use named datasource as configured. There was no problem prior to Quarkus 1.13.0.Final.

Actual behavior

Liquibase fails to find named datasources

Configuration

# Add your application.properties here, if applicable.
quarkus.datasource.devservices=false

quarkus.datasource."inventory".db-kind=postgresql
quarkus.datasource."inventory".username=inventory
quarkus.datasource."inventory".password=secret
quarkus.datasource."inventory".jdbc.url=jdbc:postgresql://localhost:5432/inventory
quarkus.datasource."inventory".jdbc.min-size=2
quarkus.datasource."inventory".jdbc.max-size=50

quarkus.liquibase."inventory".change-log=db/s3-inventory/changelog.xml
quarkus.liquibase."inventory".migrate-at-start=true
@mincel mincel added the kind/bug Something isn't working label Apr 2, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Apr 2, 2021

/cc @andrejpetras, @geoand, @gsmet

@geoand
Copy link
Contributor

geoand commented Apr 5, 2021

Would it be possible for you to attach a small project that exhibits this erroneous behavior?

Thanks

@mincel
Copy link
Author

mincel commented Apr 5, 2021

getting-started-liquibase-test.zip

When you uncomment #quarkus.datasource.devservices=false in application.properties you'll get the error.

@geoand
Copy link
Contributor

geoand commented Apr 5, 2021

I assume that the initial intention was to use quarkus.datasource.inventory.devservices=false.
I tried that but even then Quarkus starts a container for the default datasource even when though the default datasource seems to not be used at all.

When switching to quarkus.datasource.devservices=false then indeed Quarkus does turn off the dev-services for the default datasource, but a such a datasource seems to be created as CDI bean causing Liquibase to fail.

@gsmet I am not sure this is a case we formally supported - i.e. having a named datasource without having a default datasource.
If it is, then we need to figure out how to fix this use case in dev mode.

@mincel
Copy link
Author

mincel commented Apr 5, 2021

We haven't used the default datasource nor configured it in our application. We have two named datasources and two named liquibase configurations to update both databases. It is working perfectly on 1.12.x and older versions.

@geoand
Copy link
Contributor

geoand commented Apr 5, 2021

Yes I know.

What I am asking @gsmet is whether the use case with no default datasource and only named datasources is supported (which I assume it is), or if it was working up until now by accident.

@kpagratis
Copy link

kpagratis commented Mar 29, 2024

We're having a similar issue with 3.8.2
We're only using named datasources but when attempting to use liquibase we get an error

Caused by: jakarta.enterprise.inject.CreationException: Error creating synthetic bean [1d48OwssPZoQytD2p8kGRAP54yY]: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unable to find datasource '<default>' for Liquibase: Datasource '<default>' is not configured. To solve this, configure datasource '<default>'. Refer to https://quarkus.io/guides/datasource for guidance.
        at io.quarkus.liquibase.LiquibaseFactory_1d48OwssPZoQytD2p8kGRAP54yY_Synthetic_Bean.doCreate(Unknown Source)
        at io.quarkus.liquibase.LiquibaseFactory_1d48OwssPZoQytD2p8kGRAP54yY_Synthetic_Bean.create(Unknown Source)
        at io.quarkus.liquibase.LiquibaseFactory_1d48OwssPZoQytD2p8kGRAP54yY_Synthetic_Bean.create(Unknown Source)
        at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:119)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:38)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:35)
        at io.quarkus.arc.generator.Default_jakarta_enterprise_context_ApplicationScoped_ContextInstances.c32(Unknown Source)
        at io.quarkus.arc.generator.Default_jakarta_enterprise_context_ApplicationScoped_ContextInstances.computeIfAbsent(Unknown Source)
        at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:35)
        at io.quarkus.arc.impl.ClientProxies.getApplicationScopedDelegate(ClientProxies.java:21)
        at io.quarkus.liquibase.LiquibaseFactory_1d48OwssPZoQytD2p8kGRAP54yY_Synthetic_ClientProxy.arc$delegate(Unknown Source)
        at io.quarkus.liquibase.LiquibaseFactory_1d48OwssPZoQytD2p8kGRAP54yY_Synthetic_ClientProxy.getConfiguration(Unknown Source)
        at io.quarkus.liquibase.runtime.LiquibaseRecorder.doStartActions(LiquibaseRecorder.java:65)

@geoand
Copy link
Contributor

geoand commented Mar 30, 2024

@kpagratis can you please open a new issue?
Attaching a sample application that exhibits the erroneous behavior would be most helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/liquibase kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants