Spring Boot + JSP + WAR + Java 11 + GAE Standard Environment = sad

770 views
Skip to first unread message

Todd Murchison

unread,
Aug 4, 2020, 2:28:36 PM8/4/20
to Google App Engine
Hi everyone!

The story so far...
  • I built a little web app using Spring Boot with old-school JSP pages using Java 11, which runs fine locally
  • Note that Spring Boot appears to only officially support JSP with WAR packaging
  • My web app provides functionality that will only get used a few times a week (sounds like GAE Standard Environment would be perfect!)
  • I spent quite a lot of time trying to get GAE Standard deployment to to work with a WAR file (I failed)
  • I spent quite a lot of time trying to get Spring Boot with JSP working packaged as a JAR (I failed)
  • In the end, I gave up, containerized it with Docker, and deployed it to the GAE Flexible Environment instead (where it is now, working)
The usage profile of my little web app makes MUCH more sense in Standard environment and would save me $ that way.  Maybe if I...
  • Gave up on Java 11 and reverted to Java 8 I could get GAE Standard to accept a WAR file?
  • Gave up on Spring Boot and/or JSP and used some other framework / technology for my web app I could package as a JAR?
I was hoping someone might have some insight they'd be willing to share.  Does anyone know a trick to get GAE Standard to take a WAR or get Spring Boot + JSP working in a JAR?  Can WARs really be made to work if I downgrade to Java 8?  I just hate the idea of throwing money away on an ever-present instance that will only get used for a couple of hours a week, but other directions to try carry significant dev time.  Any ideas?  I'm hoping I've just missed something obvious.

Thanks!
-Todd

George (Cloud Platform Support)

unread,
Aug 4, 2020, 3:44:36 PM8/4/20
to Google App Engine
Hello Todd, 

What you aim to do it quite achievable. You may consider following the "Deploy a Spring Boot app to App Engine standard environment" example, first on page 7, and then on page 8. This lab in its entirety may prove useful. 

Todd Murchison

unread,
Aug 4, 2020, 5:44:23 PM8/4/20
to google-a...@googlegroups.com
Thanks for the response!  Unfortunately, I have already followed that code lab in my many attempts to get it to work.  What that code lab (and other documentation I've gone through) doesn't address is the use of a WAR formactor for packaging.  That code lab only works if my project is producing a JAR.  If I update the project to produce a JAR instead then the JSP pages stop working.  As best I can tell it seems that GAE:Standard:Java11 only supports deployments with JAR files, while SpringBoot:JSP only supports WAR packaging.  Do I have that wrong?

-Todd


On Tue, Aug 4, 2020 at 12:46 PM 'George (Cloud Platform Support)' via Google App Engine <google-a...@googlegroups.com> wrote:
Hello Todd, 

What you aim to do it quite achievable. You may consider following the "Deploy a Spring Boot app to App Engine standard environment" example, first on page 7, and then on page 8. This lab in its entirety may prove useful. 

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/1ec36a58-6127-4ca9-9f4a-09382f117adco%40googlegroups.com.

Rémi Bastide

unread,
Aug 5, 2020, 7:11:14 AM8/5/20
to Google App Engine
Maybe porting your JSPs to Tymeleaf and packaging as JAR ?

Alexis (Google Cloud Platform Support)

unread,
Aug 6, 2020, 5:52:46 PM8/6/20
to Google App Engine
Hello Todd,

You are correct for the support of App Engine Standard with JAR and if you prefer WAR it's understandable. There is a possible workaround here[1] but that's for old Java 7 and I think now 8. There is an old discussion about that here[2]. Deploying it in Flex is the better option. However, there is an explanation here[3], under "What are the changes between the Java 8 and Java 11 standard runtimes?", as to why it's not compatible. It's due to the API. To be future-proof, it might be best to stay with the Flex engine. I understand Standard engine is cheaper, but the API is older.

Ronoaldo Pereira

unread,
Aug 6, 2020, 7:35:04 PM8/6/20
to Google App Engine
Hi Todd, adding to Alexis answer, maybe this can be helpful: it shows a working sample of a WAR -> JAR migration: https://cloud.google.com/appengine/docs/standard/java11/java-differences#war_migration_example

My understanding from the docs is that the Java 11 runtime requires you to have a main method, and your main method must be a valid HTTP Server implementation. The HTTP Server used (the link uses  com.sun.net.httpserver.HttpServer one)  need to have support for compiling JSPs. Maybe you can bundle your WAR output and use Jetty as the main entrypoint using the Jetty embedded into your app? https://examples.javacodegeeks.com/enterprise-java/jetty/jetty-jsp-example/

There is also a way to "precompile" JSPs as part of the build, and that will transpile them into servlets making them compatible with the runtime. The old Java SDKs did that during app deployment as part of the "appcfg update" step. If you use maven this plugin seems to do that as part of the build process:  https://sling.apache.org/components/jspc-maven-plugin/ 

Hope this helps! 

pravanjan palai

unread,
Aug 15, 2020, 4:11:42 PM8/15/20
to Google App Engine
Hello Todd,
    I have created a sample example with Java 11 with Spring Boot war type and successfully tested. Please follow this  Github link for complete detail. Do let me know if it works for you. 

Thanks,
Pravanjan

Todd Murchison

unread,
Aug 15, 2020, 4:48:13 PM8/15/20
to google-a...@googlegroups.com
Oh very cool!  It looks like the secret sauce is in the "internalResourceViewResolver()" method?  I will give this a try this coming week.  Thanks for the helping hand!
-Todd


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages