-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Flyway says No database found to handle jdbc:postgresql://localhost:5432/postgres
when using java migrator in jar only
#3889
Comments
Thank you for your issue. I cannot initially see what would be causing the issue. However, because you are using Kotlin and I am unsure how Flyways service loader reacts in a Kotlin environment, I will need to do some investigation. |
In the meanwhile, would you be able to enable any sort of debug logging in your application to allow Flyway to log more debug information to potentially help locate the issue. |
Turned on the debugger for flyway and here is the output for running with gradle vs jar. Although I'm not sure how helpful turning on the debug logs are since flyway is crashing the app before its able to log anything. Is there something else I could do to get more detailed logs? I had updated my logback configuration with the following to get the debug info from flyway: <configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="trace">
<appender-ref ref="STDOUT"/>
</root>
<logger name="io.netty" level="INFO"/>
<logger name="org.flywaydb" level="DEBUG"/>
</configuration> Successful migration with gradle
Failing migration with java jar
|
This works for me as a solution. val pg = PGSimpleDataSource()
pg.setUrl("jdbc:postgresql://localhost:5432/db?user=user&password=password")
val flyway = Flyway.configure().dataSource(pg).load()
flyway.migrate() Make sure to add |
So I tried @lilyrrose 's solution but then I was getting an error similar to: Digging through that issue, came across a comment talking about needing maven shade because flyway uses service loader instead of Java reflection. I couldn't find maven shade for a gradle project, but found shadowjar and got it working when running from the jar. plugins {
id("com.github.johnrengelman.shadow") version "8.1.1"
}
tasks {
shadowJar {
archiveBaseName.set("backend")
archiveVersion.set("0.0.1")
archiveClassifier.set("")
manifest {
attributes["Main-Class"] = "com.plusmobileapps.wolfpack.backend.ApplicationKt"
}
from(sourceSets.main.get().output)
configurations = listOf(
project.configurations.runtimeClasspath.get()
)
}
task("stage") {
dependsOn(shadowJar)
mustRunAfter("clean")
}
} |
Which version and edition of Flyway are you using?
10.12.0
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)
Java API. Gradle wrapper version 8.4
Which database are you using? (Type & version)
Postgres 12.18
driver 42.7.2
Which operating system are you using?
Mac OS sonoma 14.4.1
What did you do? (Please include the content causing the issue, any relevant configuration settings, the SQL statement(s) that failed (if any), and the command you ran)
What did you expect to see?
After running the stage task which builds the jar file, the migrator should run successfully upon app startup:
This works fine when running from the command line with the gradle wrapper, it only seems to have an error when running from the jar file.
What did you see instead?
Related
I have already come across a couple of issues with some suggestions which I had included in this solution, but still can't seem to get this to work with the jar.
No database found to handle jdbc:postgresql://localhost/access_point
when deployed as Jar #3722The text was updated successfully, but these errors were encountered: