Is it possible to deploy a Java Servlet to GAE?

2020-02-13 03:47发布

Is it possible to deploy a Java Servlet to GAE, or does the server need to be hosted elsewhere?

2条回答
Evening l夕情丶
2楼-- · 2020-02-13 04:19

Short answer: Yes

Slightly longer answer:

App Engine uses the Jetty servlet container to host applications and supports the Java Servlet API version 2.4. Keep in mind though that there are quite a few restrictions in place that you have to respect (source):

  • App Engine runs a version of Java 6 but does not provide all Java classes, for example Swing and most AWT classes are not supported.
  • You cannot use Threads or frameworks which use Threads.
  • You may not write to the filesystem.
  • You may only read files which are part of your application.
  • Certain "java.lang.System" actions, e.g. gc() or exit() will do nothing.
  • You can not call JNI code.
  • Reflection is possible for your own classes and standard Java classes, but your cannot use reflection to access other classes outside your application.
  • A servlet must reply within 30 seconds or a com.google.apphosting.api.DeadlineExceededException is thrown.
  • See here for the Java classes that are white-listed.

Be sure to also read up on The Sandbox to see examples of what will and will not work.

查看更多
一纸荒年 Trace。
3楼-- · 2020-02-13 04:24

You can deploy a basic servlet to GAE, but there are additional things you need to do for GAE to accept it.

I would highly recommend a quick web search on the topic. You will find that there are tons of resources for this, including the documentation at the GAE site itself.

查看更多
登录 后发表回答