With the recent announcement of support for Servlet 3.1, I cannot figure out how to modify the App Engine Standard environment to use 3.1 instead of 2.5 in a non-Maven build.
It seems there is no way to upgrade to 3.1?
https://cloudplatform.googleblog.com/2017/06/Google-App-Engine-standard-now-supports-Java-8.html
Here is a full example given here: https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/appengine-standard-java8/helloworld
Running procedure is also attached.
For non-maven users, you can use gradle.
In gradle build file, line number 39 denotes: https://github.com/GoogleCloudPlatform/getting-started-java/blob/master/appengine-standard-java8/helloworld/build.gradle#L39
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
Running locally:
gradle appengineRun
If you do not have gradle installed, you can run using ./gradlew appengineRun.
To use visit: http://localhost:8080/
In pom.xml, line number 62 to 70 denotes that it is using servlet version 3.1.0: https://github.com/GoogleCloudPlatform/getting-started-java/blob/master/appengine-standard-java8/helloworld/pom.xml#L66
<!-- [START servlet] -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<!-- [END servlet] -->
Hope it will clarify you.
These are the steps that should work no matter what technique is used, as long as it produces a valid war that includes javax.servlet-api:3.1.0:
1) As documented, make sure you've added <runtime>java8</runtime>
to your appengine-web.xml file
2) uncompress the war into its own separate directory
3) deploy using the appcfg.sh script found on App Engine SDK for Java bin directory. It will look something like:
/<some-path>/appengine-java-sdk-1.9.54/bin/appcfg.sh update /<some-path>/exploded-war/
Note: To verify ServletContext's version from within a servlet I've used:
ServletContext sc = req.getSession().getServletContext();
resp.getWriter().println("Servlet version = " + sc.getMajorVersion() + "." + sc.getMinorVersion());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With