I have built a WAR archive artifact with Intellij IDEA that contains a Spring Boot MVC application written in Kotlin.
Here’s the relevant contents:
$ jar tvf application.war
...
1649 [timestamp] WEB-INF/classes/org/domain/apps/App00HelloMvcKt.class
2087 [timestamp] WEB-INF/classes/org/domain/apps/App00HelloMvc.class
...
App00HelloMvcKt
contains fun main(...)
, and App00HelloMvc
is the Spring Boot application class.
MANIFEST.MF
contains Main-Class
entry:
Main-Class: org.domain.apps.App00HelloMvcKt
However, when I run it, there is a problem:
$ java -jar application.war
Error: Could not find or load main class org.domain.apps.App00HelloMvcKt
Caused by: java.lang.ClassNotFoundException: org.domain.apps.App00HelloMvcKt
As I understand it, with this directory structure, no additional fumbling with class path is required. Then why is it unable to run?
Additional info: This is a teaching project. I am trying to serve .jsp
pages from Spring Boot MVC application with embedded Tomcat. According to the internet, this setup only works if you package the app into a WAR and run it with java -jar
.
Most likely IntelliJ "Web Application: Archive" doesn't fully understand Spring Boot semantics. Try packaging the WAR with Maven Spring Boot Plugin, as in explained in chapter 68.2 Packaging Executable Jar and War Files:
$ mvn clean package spring-boot:repackage
$ java -jar target/application.war