Reputation: 4119
when running gcloud app deploy
on my spring boot app, this error happens in Cloud Build.
Upvotes: 5
Views: 4580
Reputation: 91
The root cause is the fact that the packaged .jar
file does not have a Main-Class
entry in /META-INF/MANIFEST.MF
.
My original MANIFEST.MF
file looked like this:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven 3.8.6
Built-By: me
Build-Jdk: 19.0.1
For me, the solution was to add the maven-jar-plugin
and manually configure the mainClass
.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>my.main.MainClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
This resulted in the following MANIFEST.MF
Manifest-Version: 1.0
Created-By: Maven JAR Plugin 3.3.0
Build-Jdk-Spec: 19
Main-Class: my.main.MainClass
You could also check https://www.baeldung.com/spring-boot-main-class for other options, but then you'll have to use spring-boot-starter-parent
as parent...
Upvotes: 0
Reputation: 91
I was able to fix it for my AppEngine + Gradle project by adding
jar {
enabled = false
archiveClassifier = ''
}
to the build.gradle file.
Upvotes: 2
Reputation: 735
There can be one or many issues because of which you get this error. For resolution please check below things -
Your app.yaml
should have entrypoint and runtime information as below -
runtime: java11
entrypoint: java -Xmx64m -jar blahblah.jar
your pom.xml
should have appengine maven plugin dependency
`
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.2.0</version>
</plugin>
`
don't modify jar if you want to replace any configs use command -
jar uf blahblah.jar filename.yaml
make sure you have packaging as a jar in pom.xml
like this -
<packaging>jar</packaging>
Upvotes: 8
Reputation: 49
Try to comment out in pom.xml packaging into war file, example:
<!-- <packaging>war</packaging> -->
It fixed the issue for me. Good minimal+workable example is here: https://codelabs.developers.google.com/codelabs/cloud-app-engine-springboot#0
Upvotes: 1
Reputation: 4119
I deleted my maven plugin by accident, so don't delete it.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
Upvotes: 3