4

I have ported my Google App Engine application to recent Java 8 runtime environment. The application works fine, with a few issues.

I have ported my code to use java.time instead of Joda time, but the app engine server throws error when responding to requests:

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

at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:50)

This happens on a development server only, production server seems to be running fine.

The documentation says:

  • Doesn't impose a security manager as the Java 7 runtime does, which means your code won't be restricted by Java permissions issues.
  • Supports the standard public Java library, not just the whitelisted class subset available for the Java 7 runtime.

When searching for this error, I found mentions about file access being prohibited, which I understand, but I do not see how this applies to java.time package. Moreover, the mentions I have found (like this SO question) seem to be about Java 7 runtime environment.

It is not very pressing, I can stay with Joda time, but it was a surprise for me.

Is this expected, or is it a bug, or am I doing something wrong?

M. Prokhorov
  • 3,894
  • 25
  • 39
Suma
  • 33,181
  • 16
  • 123
  • 191
  • I'm facing the same issue with my Scala + sbt setup. Seems odd, because the documentation promises that the java8 time API is fully supported. Did you find out anything more about that? – Taig May 09 '18 at 16:13
  • I stay with Joda time, I did not experiment with that any more. – Suma May 09 '18 at 20:23

2 Answers2

1

I can confirm that I use Java8 features including java.time in both the development environment and the production servers.

It is likely to be a Java 7 SDK that is being used to run your dev server. Check your build environment setup.

Make sure you have the latest app engine API jars in your WEB-INF/lib.

You also need to add java8 to your appengine-web.xml

Dev Vercer
  • 166
  • 1
  • 7
  • 1
    Interesting to hear that, thanks. I followed your checklist, not much luck so far: Dev Server is running on Java\jdk1.8.0_92\bin, WEB-INF/lib contains appengine-api-1.0-sdk-1.9.54.jar, appengine-web.xml contains java8. My build environment is a bit unusual, I am using Scala, IntelliJ IDEA and SBT, but I do not think this should play any role here. Do you use App Engine SDK, or the new Cloud SDK? – Suma Aug 23 '17 at 13:41
0

Faced the same issue. It's with InteliJ plugin as it seems. Run from the maven plugin as a work around.

enter image description here

Don Srinath
  • 1,565
  • 1
  • 21
  • 32
  • 2
    I confirm I am using IntelliJ as well. I will try to check your workaround - I hope I will be able to do it, I have no experience with Maven or its plugins. – Suma Feb 11 '18 at 09:29