quarkus icon indicating copy to clipboard operation
quarkus copied to clipboard

Flyway: Java-migrations picked up everywhere

Open wicksim opened this issue 1 year ago • 8 comments

Describe the bug

When working with Java-migrations with quarkus-flyway, every class in the classpath extending org.flywaydb.core.api.migration.JavaMigration is picked up, independent of what is configured in quarkus.flyway.locations.

As far as I can see, FlywayProcessor just searches for implementors of JavaMigration without considering quarkus.flyway.locations.

Expected behavior

Java-Migrations should only be picked up if they are in a classpath defined in quarkus.flyway.locations.

Actual behavior

All the Java-migrations found everywhere are picked up for migration.

How to Reproduce?

Reproducer: flyway-classpath-reproducer.zip

Steps to reproduce:

  1. Start app
  2. Java-migration is executed (see message in sysout)

Output of uname -a or ver

Microsoft Windows [Version 10.0.19044.1889]

Output of java -version

openjdk version "17.0.4.1" 2022-08-12 LTS OpenJDK Runtime Environment Corretto-17.0.4.9.1 (build 17.0.4.1+9-LTS) OpenJDK 64-Bit Server VM Corretto-17.0.4.9.1 (build 17.0.4.1+9-LTS, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.13.2.Final

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

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)

Additional information

No response

wicksim avatar Oct 13 '22 04:10 wicksim

/cc @cristhiank, @gastaldi, @geoand, @gsmet

quarkus-bot[bot] avatar Oct 13 '22 04:10 quarkus-bot[bot]

@gastaldi can you please run the tests of the flyway module from the current main? They seem to be failing for me...

geoand avatar Oct 13 '22 06:10 geoand

As for this issue itself, I think we first need to address https://github.com/quarkusio/quarkus/issues/21275 (or decide if this is actually a duplicate). @gastaldi @gsmet WDYT?

geoand avatar Oct 13 '22 06:10 geoand

@gastaldi can you please run the tests of the flyway module from the current main? They seem to be failing for me...

@geoand I ran the tests locally and they pass for me, can you paste the stacktrace?

gastaldi avatar Oct 13 '22 15:10 gastaldi

Thanks for checking, there must be something wrong going on for me locally. I get:

2022-10-13 18:19:56,970 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-0) HTTP Request to /fly failed, error id: a38447f9-228d-4502-a5ee-bbda6d2d6ce7-1: org.jboss.resteasy.spi.UnhandledException: javax.enterprise.inject.UnsatisfiedResolutionException: No bean found for required type [class org.flywaydb.core.Flyway] and qualifiers [[@javax.enterprise.inject.Default()]]
        at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:105)
        at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:359)
        at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:218)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:519)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
        at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:91)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:564)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: No bean found for required type [class org.flywaydb.core.Flyway] and qualifiers [[@javax.enterprise.inject.Default()]]
        at io.quarkus.arc.impl.InstanceImpl.bean(InstanceImpl.java:191)
        at io.quarkus.arc.impl.InstanceImpl.getInternal(InstanceImpl.java:212)
        at io.quarkus.arc.impl.InstanceImpl.get(InstanceImpl.java:97)
        at io.quarkus.flyway.test.DevModeTestEndpoint.present(DevModeTestEndpoint.java:18)
        at io.quarkus.flyway.test.DevModeTestEndpoint_Subclass.present$$superforward1(Unknown Source)
        at io.quarkus.flyway.test.DevModeTestEndpoint_Subclass$$function$$1.apply(Unknown Source)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
        at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
        at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:33)
        at io.quarkus.flyway.test.DevModeTestEndpoint_Subclass.present(Unknown Source)
        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 org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
        at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
        at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:408)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:69)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
        ... 15 more

geoand avatar Oct 13 '22 15:10 geoand

That's really weird, I can't reproduce it . Maybe it's a consequence of other error? Does it still happen if you mvn -Dquickly the whole project with any IDEs closed?

gastaldi avatar Oct 13 '22 15:10 gastaldi

Dunno, I have no idea. It happens when I try to install the extension.

geoand avatar Oct 13 '22 15:10 geoand

As for this issue itself, I think we first need to address #21275 (or decide if this is actually a duplicate). @gastaldi @gsmet WDYT?

This stills stands, we'll need to figure out how to address it @gastaldi @gsmet

geoand avatar Oct 14 '22 15:10 geoand