Spring Boot application stops immediately after start-up
Answered
Hello,
I migrated my project from Maven to Gradle and it works fine when I start the application using gradle run task. However, when I try to run it with Application run configuration it starts, but then immediately terminates without any error. From the logs it looks like Tomcat is not starting.
Here are the logs when I run the applicatation via Gradle task:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.5.RELEASE)
2020-11-02 19:05:29.318 INFO 15776 --- [ main] c.v.nonogram.server.NonogramServer : Starting NonogramServer on DESKTOP-SUL63CS with PID 15776 (D:\Biblioteki\Documents\Projects\IntelliJ\nonogram\server\build\classes\java\main started by karwa in D:\Biblioteki\Documents\Projects\IntelliJ\nonogram\server)
2020-11-02 19:05:29.320 INFO 15776 --- [ main] c.v.nonogram.server.NonogramServer : No active profile set, falling back to default profiles: default
2020-11-02 19:05:29.984 INFO 15776 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-11-02 19:05:29.993 INFO 15776 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-11-02 19:05:29.993 INFO 15776 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.39]
2020-11-02 19:05:30.059 INFO 15776 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-11-02 19:05:30.059 INFO 15776 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 708 ms
2020-11-02 19:05:30.309 INFO 15776 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-11-02 19:05:30.317 INFO 15776 --- [ main] c.v.nonogram.server.NonogramServer : Started NonogramServer in 1.245 seconds (JVM running for 1.505)
And here are the logs when running with Application run configuration:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.5.RELEASE)
2020-11-02 19:06:24.473 INFO 19128 --- [ main] c.v.nonogram.server.NonogramServer : Starting NonogramServer on DESKTOP-SUL63CS with PID 19128 (D:\Biblioteki\Documents\Projects\IntelliJ\nonogram\server\build\classes\java\main started by karwa in D:\Biblioteki\Documents\Projects\IntelliJ\nonogram)
2020-11-02 19:06:24.475 INFO 19128 --- [ main] c.v.nonogram.server.NonogramServer : No active profile set, falling back to default profiles: default
2020-11-02 19:06:24.836 INFO 19128 --- [ main] c.v.nonogram.server.NonogramServer : Started NonogramServer in 0.553 seconds (JVM running for 0.861)
Here is a screenshot of my run configuration:
Project code can be found under this link: https://gitlab.com/Verntrax/nonogram. Module with the application has the name "server".
Thank you
Please sign in to leave a comment.
Why do you need to start the application using Application run configuration? Isn't it better to use Spring?
To be honest, I don't know what is the difference other than that the Spring run configuration offers more options. I guess I did it this way, because Application run configuration is just something I'm more used to. Anyway, I've created the following Spring Boot configuration and the problem is still the same:
For me, Spring boot configuration works as expected.
See this thread: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360009249140-Spring-Boot-stop-immediately-after-start-up
Users report that re-creating project from scratch helps. So, try removing the .idea folder and .iml file in project's root. Re-import the project to IDE after that.
Recreating the project fixed the problem. Thank you!