简体   繁体   中英

WebServlet annotation not working in production (works in development)

I am using Google App Engine STANDARD (SDK 1.9.62) and have set my appengine-web.xml to use java8 runtime and trying to get a simple servlet example . Works as expected in local dev server but gives me a 404 error in the google cloud. I WANT to use the Google App Engine standard environment (not flex). Is there a yaml entry or xml entry I need to turn on for this to work? How can I be sure that GAE is using the 3.1 servlet spec and not 2.5?

App Engine Standard uses appengine-web.xml , whereas Flexible uses app.yaml .

Now, this Java-docs-sample us using the pom.xml to set dependencies. you can see the versions of the dependencies set there.

In this case, that sample can be deployed with mvn appengine:deploy and the endpoint serving in App Engine would be /requests. ie https://project-name.appspot.com/requests which should return a "hello, world"

Ok. Mystery solved. I had two versions running in deployment and an original java7, servlet 2.5 api version was handling all traffic. My INTENDED version, which was a java8, servlet 3.x was sitting idle and getting 0% traffic. Once I used the version migration function in google's cloud console, the servlets annotated with servlet 3.x annotations started working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM