michael-simons / neo4j-migrations

Automated script runner aka "Migrations" for Neo4j. Inspired by Flyway.
https://michael-simons.github.io/neo4j-migrations/
Apache License 2.0
114 stars 23 forks source link

Springboot 3.2.X fatjar and neo4j migration #1248

Closed shanon84 closed 7 months ago

shanon84 commented 7 months ago

Hey, we run into a problem with springboot 3.2.x, fatjars and neo4j migration currently. With 3.2 springboot rewrote the hole technic to make and handle fat jars. Neo4j migration seems to not be able to work with this properly. Our setup: we have a kind of app shell. A maven project only beeing responsible for making an app/fat jar out of our libs. The neo4j migration is used inside one lib. If we build a fat jar and start it with java -jar ourjar.jar neo4j migration cannot open the migrationscripts itself. The folder they are in is correctly identified and read, but opening the first file leads to a FileNotFoundException.

For others: If you run into this problem, you can switch back to the classic way of springboot building and handling fat jars by adding

<loaderImplementation>CLASSIC</loaderImplementation>

to your spring-boot-maven-plugin config to fix the problem for now.

michael-simons commented 7 months ago

Hej @shanon84 This has been fixed I think…

https://github.com/michael-simons/neo4j-migrations/issues/1153#issuecomment-1834495373

Which version are you using?

shanon84 commented 7 months ago

springboot 3.2.2 neo4j migration 2.9.0, but I tested it again with 2.9.1: same problem. The error we are getting is the following: Caused by: java.io.FileNotFoundException: JAR entry BOOT-INF/lib/backend-neo4jmigration-mylibname-0.0.1.jar!/neo4j/migrations/2023-12/V001__init_indexes_and_constraints.xml not found

michael-simons commented 7 months ago

Can you switch back to the classic loader?

Relevant configuration for Maven Spring Boot plugin…

 <configuration>
            <loaderImplementation>CLASSIC</loaderImplementation>
          </configuration>
shanon84 commented 7 months ago

yes, as I menitioned in the first posting, this is our temporarly workaround :)

michael-simons commented 7 months ago

Aaah, sorry, I missed that. Edited some backticks in.

I try to see if find some time next week to investigate.

michael-simons commented 7 months ago

Hey @shanon84 So do I get this right: Your migrations are part of a jar which itself is part of the boot app? that is, the migrations are not direct resources of the spring boot app?

michael-simons commented 7 months ago

I am quite convinced I have the same setup in our IT:

See resources project:

https://github.com/michael-simons/neo4j-migrations/tree/main/neo4j-migrations-test-resources/src/main/resources/sb

SB integration tests depends on it https://github.com/michael-simons/neo4j-migrations/blob/5dbbe0ab5e0b5b68509729569a97b0d07bfc338c/neo4j-migrations-examples/neo4j-migrations-examples-sb/pom.xml#L60

Config pointing to it: https://github.com/michael-simons/neo4j-migrations/blob/bf4b3e13516cc5ee32cd098cb06d8d56110f8686/neo4j-migrations-examples/neo4j-migrations-examples-sb/src/main/resources/application.properties#L17

Integration tests goes a couple of miles to make sure it's running the jar https://github.com/michael-simons/neo4j-migrations/blob/bf4b3e13516cc5ee32cd098cb06d8d56110f8686/neo4j-migrations-examples/neo4j-migrations-examples-sb/src/test/java/ac/simons/neo4j/migrations/examples/sb/ApplicationIT.java#L85

michael-simons commented 7 months ago

Ha! Can replicate it. Thanks for involuntary rubber-ducking with me!

michael-simons commented 7 months ago

This is fixed in 2.9.2, which is on its way to central. Thanks for your report!