Suma
Suma

Reputation: 34413

Google App Engine on Java 8 - java.time not available on dev. server?

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?

Upvotes: 4

Views: 978

Answers (2)

Don Srinath
Don Srinath

Reputation: 1593

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

Upvotes: 0

Dev Vercer
Dev Vercer

Reputation: 196

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

Upvotes: 1

Related Questions