I'm building out a REST API for a personal project, using Spring Boot to do so, and deploying onto Google App Engine. The project compiles and runs locally with no issues, and I can deploy to GAE with no build errors. However, when I navigate to my URI after I deploy to GAE, a 404 is thrown with the following message:
No context on this server matched or handled this request.
Contexts known to this server are:
/ ---> o.e.j.w.WebAppContext@56ef9176{/,file:///var/lib/jetty/webapps/root/,UNAVAILABLE}{/root.war} [failed]
I have both a build.gradle and pom.xml file, and dependencies have to be declared in both, which I believe is the issue.
My pom.xml contains:
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.0.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
My build.gradle contains:
plugins {
id 'org.springframework.boot' version '2.0.1.RELEASE'
}
apply plugin: 'io.spring.dependency-management'
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
}
When I remove both of the spring boot dependencies from both, the error disappears.
Any ideas?
Figured it out myself in the end, but will leave this up for anyone else who stumbles across the same error.
As I found in the docs: if you're using a WAR as your deployable (instead of a .jar file) then you must also import spring-boot-starter-tomcat
as a provided dependency.
My pom.xml now looks like:
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.0.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
And my build.gradle now looks like:
plugins {
id 'org.springframework.boot' version '2.0.1.RELEASE'
}
apply plugin: 'io.spring.dependency-management'
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
}