google-app-engine


Google App Engine, Spring Boot app keeps restarting


I am trying to build a Spring Boot REST API and host it on Google's App Engine. I prefer gradle in my projects at work, so I chose to use Gradle. The documentation is challenging to navigate.
I finally got the proper gradle file to work, and the proper app.yaml configuration. But my spring boot app just keeps restarting on App Engine. It automatically restarts regardless of any external influence (theres no errors when hitting an endpoint; the app works just like it should locally... for all of a few seconds).
I am having a very hard time debugging it.
Here are the last few logs before it restarts again. It looks like SpringFrameworkServlet is causing the issues and making it restart? Because I dont have any Servlets in my code, but im pretty sure App Engine has something with Servlets baked into its Java docker container.
A 2017-04-25 14:01:26.604 INFO 1 --- [ main] o.s.d.r.w.BasePathAwareHandlerMapping : Mapped "{[/profile/{repository}],methods=[GET],produces=[application/schema+json]}" onto public org.springframework.http.HttpEntity<org.springframework.data.rest.webmvc.json.JsonSchema> org.springframework.data.rest.webmvc.RepositorySchemaController.schema(org.springframework.data.rest.webmvc.RootResourceInformation)
A 2017-04-25 14:01:27.362 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
A 2017-04-25 14:01:28.937 INFO 1 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
A 2017-04-25 14:01:29.281 INFO 1 --- [ main] io.stevers.babli.BabliApplication : Started BabliApplication in 34.136 seconds (JVM running for 39.899)
A 2017-04-25 14:01:30.978 INFO 1 --- [nio-8080-exec-9] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
A 2017-04-25 14:01:30.982 INFO 1 --- [nio-8080-exec-9] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
A 2017-04-25 14:01:31.126 INFO 1 --- [nio-8080-exec-9] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 144 ms
A -XX:InitialHeapSize=514850816 -XX:MaxHeapSize=514850816 -XX:+ParallelRefProcEnabled -XX:+PrintCommandLineFlags -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseG1GC
A openjdk version "1.8.0_121"
A OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-1~bpo8+1-b13)
A OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)
A
A
app.yaml
runtime: java
env: flex
service: springboot
runtime_config: # Optional
jdk: openjdk8
manual_scaling:
instances: 1
build.gradle
buildscript {
ext {
springBootVersion = '1.5.3.BUILD-SNAPSHOT'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath('com.google.cloud.tools:appengine-gradle-plugin:1.3.0')
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'com.google.cloud.tools.appengine'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-jersey')
compile('org.springframework.boot:spring-boot-starter-data-rest')
compile('org.springframework.boot:spring-boot-starter-web')
compile('com.h2database:h2')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('org.webjars:bootstrap:3.3.6')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
Thanks to the two github users, I identified my issue.
My server was restarting due to failing the health checks. When your service fails a health check, it is restarted. So the options for fixing this are as follows:
1) Disable health checks. Add this to your app.yaml
health_check:
enable_health_check: False
2) Make sure your server returns a 200 or 404 for the /_ah/health end point. I added a simple REST Controller for that.
#RequestMapping("/_ah/health")
public ResponseEntity<String> healthCheck() {
return new ResponseEntity<>("Healthy", HttpStatus.OK);
}
I hope this helps someone else! I got stuck for a day and a half on this :(.

Related Links

Are repeated properties equivalent to array properties?
X-AppEngine-Country removed from Google App Engine HTTP Headers
Is it cost-effective to store images inside a folder rather than the Google Cloud storage?
Gorilla websocket with google app engine
Appengine ndb - How to ensure unique username and email without ancestors?
Is the Cloud Datastore Emulator a dropin replacement for the local Datastore that is part of the Eclipse AppEngine plugin?
How do I create/use a GWT Client for AppEngine Endpoints?
Query by multiple doc_ids in Google App Engine Search API
Appengine ndb - Transactions can report failure but succeed
ImportError: No module named _ctypes running Python Flask tutorial for Google App Engine on Windows
Gcloud custom domain
Not getting all labels with Adwords Python client
Standard for Google Cloud and AWS Setup for multiple instances
GAE custom domain wildcard subdomain issues
Cron per Service/Module (AppEngine)
How do we parse and generate App Engine URL-Safe Datastore Keys in the Google Cloud API?

Categories

HOME
go
maxscript
banner
crystal-lang
discrete-mathematics
p2p
fosrestbundle
jquery-ui-sortable
octave
text-mining
plist
php-5.6
cumulocity
http-post
feathersjs
cfml
microsoft-ocr
user-experience
jquery-ias
cgbitmapcontext
string-concatenation
interpreter
jquery-callback
tiki-wiki
siri
entity-relationship-model
volatile
mustache
turfjs
dumpbin
quickfixj
hard-drive
roblox
video-capture
swagger-php
cin
portforwarding
subclipse
avcapturedevice
wc
vaadin-charts
bluez
aquamacs
skin
type-theory
pocketsphinx-android
chromium-os
installshield-2010
gogs
embedding
http-status-code-401
riot
piracy-prevention
oracle-spatial
poppler
fuelcms
dock
haskell-warp
baasbox
skspritenode
osc
mass-assignment
structuremap3
verold
reflector
cancellation
ray
mt4j
rolify
actiondispatch
swfobject
onmousemove
objectquery
cross-database
google-maps-mobile
massive
xui
inline-formset
twitterizer
sun
xpsdocument
todos
entitykey
product-management
wcf-proxy

Resources

Encrypt Message