Spring Boot Flyway migrations not executed, SQL files are in JAR - spring-boot

I have a Spring Boot application using Flyway Migrations. Everything runs fine, from:
within IntelliJ
from the terminal on my macbook
With 'fine' I mean, migration files are found, which are placed in src/main/resources and end up in the Spring Boot executable jar.
However, when I run the jar from the commandline on Centos 6.8, Flyway is unable to find the migration files.
Any ideas?
Using Java 8.

The easiest way to resolve it is to open at your logger the package org.flywaydb to loglevel DEBUG and retry. For sure you'll find the initial clue.
Good luck

Related

Spring boot version 2.5.5 unable to create docker image for copy command

After upgrading my spring-boot application from spring-boot version 2.3.9 to 2.5.12
We have started getting below exception. Not sure if there is change related to docker in spring boot version 2.5.12
With previous version it was working fine but after changing gradle to 6.8 and spring-boot version this issue started ... any workaround to fix this issue?
This is the command that causes error in Dockerfile
ENV APP_HOME=/app/z-api/
COPY --from=build "${APP_HOME}build/libs/z-api-*.jar" app.jar
COPY --from=build "${APP_HOME}build/libs/z-api-*.jar" app.jar
When using COPY with more than one source file, the destination must be a directory and end with a /
There are now two jars in build/libs that match z-api-*.jar. This is due to Spring Boot 2.5 no longer disabling the jar task by default. From the release notes:
The Spring Boot Gradle Plugin no longer automatically disables the standard Gradle jar and war tasks. Instead we now apply a classifier to those tasks.
If you prefer to disable those tasks, the reference documentation includes updated examples.
You could update your COPY command so that it doesn’t match the -plain.jar that’s now produced by the jar task. Alternatively, you could disable the jar task:
jar {
enabled = false
}
As #andy-wilkinson explained, the reason is that 2 jar files are generated by Gradle as
<appname>-0.0.1-SNAPSHOT.jar
<appname>-0.0.1-SNAPSHOT-plain.jar
If you prefer that the plain archive isn’t built at all, disable its task.
If you are using Kotlin with Gradle, add the following script to build.gradle.kts
tasks.named<Jar>("jar") {
enabled = false
}
Read more on https://docs.spring.io/spring-boot/docs/2.5.x/gradle-plugin/reference/htmlsingle/#packaging-executable.and-plain-archives

Should I use spark-submit if using spring boot

What is the purpose of spark submit? From what I can see it is just adding properties and jars to the classpath.
If I am using spring boot can I avoid using spark-submit, and just package a fat jar with all the properties I want spark.master etc...
Can ppl see any downside to doing this?
recently I met same case - and also try to stick to spring boot exec jar which unfortunately failed finally, but I was close to end. the state when I gave up was - spring boot jar built without spark/hadoop libs included, and i was running it on a cluster with -Dloader.path='spark/hadoop libs list extracted from SPARK_HOME and HADOOP_HOME on cluster'. I ended up using 2d option - build fat jar with shaded plugin and running it as usual jar by spark submit which seems to be a bit strange solution but still works ok

Placeholder in banner.txt are not replaced when deploying war file

I've built a spring boot application and I'm trying to customize the banner to display the version of my application.
After reading the documentation, I've managed to create a banner.txt in the classpath and added the ${application.formatted-version} placeholder inside.
I've also managed to create a manifest file (using Gradle) containing the Implementation-Version.
Everything works fine when executing a jar file directly but when creating a war file, the banner is displayed but the version placeholder is not replaced.
After a bit of debugging, this method seems to be the source of the problem
org.springframework.boot.ResourceBanner.getApplicationVersion()
When running a war file, the call to
sourcePackage.getImplementationVersion() always return null
The manifest file is located at the root of the war file /META-INF/MANIFEST.MF
The application is deployed in a standalone tomcat 8.0.15
Any idea of what's wrong ?
It's a bug/limitation in Tomcat. It fails to find the /META-INF/MANIFEST.MF from an exploded WAR file which causes its ClassLoader to define the package with a null implementation version. This has been fixed in Tomcat, but the fix hasn't made it into a release yet. It'll be in 8.0.25.
There's some more information in this Spring Boot issue and this is the change that was made to Tomcat if you're interested.

Grails run-app causes error generating web.xml file and bootstrap.groovy not included in war file

I am working on an maven application. When I run it from IntelliJ, it successfully launches my application. But bootstrap.groovy file is not being read. I have created a new username to be added to DB in bootstrap and it should allow me to login to the application using that username for the first time. This is not getting invoked during the start of the program. What settings should I do to include bootstrap.groovy.
The same happens when I create a war file and deploy it in the test server. Bootstrap.grrovy is not read. To create the war file, I use mvn package in command line.
My other question with the same application is that when I do grails run-app, I get the following error: Error generating web.xml file.
What is that I am missing? Please let me know.
Well, I fixed the issue. The web.xml was created when I changed the grails dependent jar. I was using 2.3.4 in my application and my jar was incompatible as I had 2.4.3 version of the jar. Now my program is up and running! Hope this helps someone who is facing the same problem.

grails tomcat 7 deployment

So I have a grails 2.0.4 application that works exactly the way I want. I created the war file and deployed it to Tomcat 7. I'm getting an error saying that the application can't find the jar I'm using to connect to oracle (ojdbc6.jar). The jar is listed under mywebapp/WEB-INF/lib. WHY can't it be found?? Any help would be greatly appreciated!
The jar file should be in the toplevel lib directory of your project (or specified as a dependency in a repository), not webapp/WEB-INF/lib. Is the jar file actually inside the warfile? You can test this by opening the war as a zip file, or by running jar tf target/mywebapp*.war and looking for ojdbc6.jar. If it is, it should get deployed and you should see it in tomcat7/webapps/mywebapp/WEB-INF/lib.
The default environment for grails war is production instead of development. Make sure you've got the production data source configured correctly in grails-app/conf/DataSource.groovy

Resources