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

FlywayAutoConfiguration filesystem: prefix fails #13862

Closed
andyrbell opened this issue Jul 22, 2018 · 1 comment
Closed

FlywayAutoConfiguration filesystem: prefix fails #13862

andyrbell opened this issue Jul 22, 2018 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@andyrbell
Copy link

Flyway locations can be prefixed with "classpath: or "filesystem:".

FlywayAutoConfiguration by default checks at least one location exists.

That check fails when using the "filesystem:" prefix due to:

java.net.MalformedURLException: unknown protocol: filesystem

which results in the following:

Caused by: java.lang.IllegalStateException: Cannot find migrations location in: [filesystem:src/main/resources/db/migration] (please add migrations or check your Flyway configuration)
    at org.springframework.util.Assert.state(Assert.java:94)
    at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.checkLocationExists(FlywayAutoConfiguration.java:168)
    at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.flyway(FlywayAutoConfiguration.java:152)
    at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$65b82c95.CGLIB$flyway$1(<generated>)
    at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$65b82c95$$FastClassBySpringCGLIB$$bf4a67a0.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
    at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$65b82c95.flyway(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
    ... 70 more

If the prefix is changed to "file:", the FlywayAutoConfiguration check succeeds but then Flyway throws an exception:

Caused by: org.flywaydb.core.api.FlywayException: Unknown prefix for location (should be either filesystem: or classpath:): file:src/main/resources/db/migration
    at org.flywaydb.core.api.Location.<init>(Location.java:71) ~[flyway-core-5.1.4.jar:na]
    at org.flywaydb.core.internal.util.Locations.<init>(Locations.java:46) ~[flyway-core-5.1.4.jar:na]
    at org.flywaydb.core.api.configuration.ClassicConfiguration.setLocationsAsStrings(ClassicConfiguration.java:864) ~[flyway-core-5.1.4.jar:na]
    at org.flywaydb.core.Flyway.setLocations(Flyway.java:518) ~[flyway-core-5.1.4.jar:na]
    at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$SpringBootFlyway.setLocations(FlywayAutoConfiguration.java:285) ~[spring-boot-autoconfigure-2.1.0.BUILD-SNAPSHOT.jar:2.1.0.BUILD-SNAPSHOT]
    at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.flyway(FlywayAutoConfiguration.java:175) ~[spring-boot-autoconfigure-2.1.0.BUILD-SNAPSHOT.jar:2.1.0.BUILD-SNAPSHOT]
    at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$ae83b85c.CGLIB$flyway$0(<generated>) ~[spring-boot-autoconfigure-2.1.0.BUILD-SNAPSHOT.jar:2.1.0.BUILD-SNAPSHOT]
    at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$ae83b85c$$FastClassBySpringCGLIB$$d56b3dc1.invoke(<generated>) ~[spring-boot-autoconfigure-2.1.0.BUILD-SNAPSHOT.jar:2.1.0.BUILD-SNAPSHOT]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.0.BUILD-SNAPSHOT.jar:5.1.0.BUILD-SNAPSHOT]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.1.0.BUILD-SNAPSHOT.jar:5.1.0.BUILD-SNAPSHOT]
    at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$ae83b85c.flyway(<generated>) ~[spring-boot-autoconfigure-2.1.0.BUILD-SNAPSHOT.jar:2.1.0.BUILD-SNAPSHOT]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.0.BUILD-SNAPSHOT.jar:5.1.0.BUILD-SNAPSHOT]
    ... 70 common frames omitted

A workaround is to disable the check:

spring.flyway.check-location=false

This repository replicates the issue: https://github.com/andyrbell/spring-boot-flyway-issue

These various issues appear relate to the same problem:

https://stackoverflow.com/questions/49572576/spring-boot-flyway-autoconfiguration
flyway/flyway#1982
#13190

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 22, 2018
andyrbell added a commit to andyrbell/spring-boot that referenced this issue Jul 22, 2018
Allows a Flyway location with a filesystem prefix to be validated.

Fixes spring-projectsgh-13862
@snicoll
Copy link
Member

snicoll commented Jul 23, 2018

@andyrbell thanks for raising this and the PR. Let's continue the discussion on the latter.

@snicoll snicoll closed this as completed Jul 23, 2018
@snicoll snicoll added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants