Can't start war created with Gradle BootRepackage in JHipster based web app
I am trying to run java -jar
a war file generated by ./gradlew -Pprod bootRepackage
. The task was bootRepackage
completed successfully.
When I look at the folder project_root/build/libs/
, the war and war.original files are created with the following permissions:
-rw-rw-r-- 1 user user 110376521 Apr 24 09:42 app-0.1-SNAPSHOT.war
-rw-rw-r-- 1 user user 107542786 Apr 24 09:40 app-0.1-SNAPSHOT.war.original
In my build.gradle I have the following:
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'spring-boot'
apply plugin: 'war'
bootRepackage {
mainClass = 'org.package.Application'
}
// Original from JHipster. Uncommenting this does not work either.
//springBoot {
// mainClass = 'org.package.Application'
//}
// I got this from [this][1] questions, but did not work either.
war {
baseName = 'app'
version = '0.1-SNAPSHOT'
manifest {
attributes 'Main-Class': 'org.package.Application'
}
}
When I start the jar I get:
$ java -jar app-0.1-SNAPSHOT.war --spring.profiles.active=prod
java.lang.IllegalStateException: No 'Start-Class' manifest entry specified in jar:file:/home/user/.../build/libs/app-0.1-SNAPSHOT.war!/
at org.springframework.boot.loader.archive.Archive.getMainClass(Archive.java:57)
at org.springframework.boot.loader.ExecutableArchiveLauncher.getMainClass(ExecutableArchiveLauncher.java:63)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:61)
at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:80)
What should I do? Thank.
Update I dug up the war and looked into MANIFEST.MF:
Manifest-Version: 1.0
Start-Class: org.package.Application
Spring-Boot-Version: 1.1.7.RELEASE
Main-Class: org.springframework.boot.loader.WarLauncher
Am I correct?
+3
source to share
1 answer
Here's a build.gradle that works, bootRepackage commented:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.3.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'spring-boot'
apply plugin: 'war'
repositories {
mavenCentral()
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
}
//bootRepackage {
// mainClass = 'org.package.Application'
// }
war {
baseName = 'app'
version = '0.1-SNAPSHOT'
manifest {
attributes 'Main-Class': 'org.package.Application'
}
}
Diff at MANIFEST.INF
> libs diff META-INF/MANIFEST.MF ~/temp/MANIFEST-MF-works
2c2
< Start-Class: org.package.Application
---
> Start-Class: Application
In action
> sample /opt/java/bin/java -jar build/libs/app-0.1-SNAPSHOT.war
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.3.RELEASE)
2015-04-24 18:44:55.443 INFO 18776 --- [ main] Application : Starting Application on vagrant-ubuntu-trusty-64 with PID 18776 (started by developer in /home/developer/developments/gradle-sandbox/sample)
+2
source to share