Using Spring Framework Inside Google App Engine
Trying to port spring project to run on google app engine came across some stumbling blocks. The following is a list of things that didn’t worked and one that worked.
Tried HSQL database did not work, running the same program but with an embedded database inside gae, but found out that you couldn’t because gae doesn’t allow you write files to disk.
Tried Spring boot + Spring data inside gae did not work, used a spring-boot-gae-example added spring data jpa to it, problem could not find how to connect to datasource got the following exception:
[INFO] Caused by: org.springframework.beans.BeanInstantiationException: Failed t o instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBea n]: Factory method 'entityManagerFactory' threw exception; nested exception is j ava.lang.NoClassDefFoundError: javax.management.NotificationBroadcasterSupport i s a restricted class. Please see the Google App Engine developer's guide for mo re details.
Tried Spring core + Spring data + Datanucleus inside gae did not work, change the program to spring core because couldn’t see what spring boot was doing behind the seens, had to add datanucleus in your pom.xml as a plugin to enhance your classes for google cloud datastore, problem could not get datanucleus:enhance to work.
Tried Spring core + Google Cloud Datastore inside gae partial work, rewrote the program i.e the DAOs to use the datastore api, problem could insert data but could not retrieve it probably because didn’t register the classes.
Tried Spring core + Objectify inside gae working, rewrote the program again this time using the objectify api, also had to create a helper class to register the classes inside the servletcontextlistener, got both web interface and restful interface working.
Add the listener to web.xml
Use the ObjectifyService to perform your CRUD functions:
Comments