Monday, December 18, 2017

Google App Engine Devserver Exception Due to FormatStyle Restricted Class

In one of my application in Google App Engine, I tried to integrated Spring MVC.

The Spring version I used was 4.0.13.

Unfortunately, after the integration, it started to throw series of Exceptions following type one after another.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Initialization of bean failed [...]

nested exception is java.lang.NoClassDefFoundError: java.time.format.FormatStyle is a restricted class. Please see the Google App Engine developer's guide for more details.

Problem and Solution

The problem was, I had been using Java 8. With the integration of Spring, Spring Libraries try to use some of the classes which are restricted in App Engine (why?). So if I downgrade Java 1.8 to 1.7 then the problem will be fixed. However this cannot be the solution as anyone wants to use the latest version of Java.

The actual problem is, even though I had been using Java 8, App Engine's target JRE was still 1.7. So to fix this problem I had to add following snippet into appengine-web.xml:

<runtime>java8</runtime>








3 comments: