Adding JSP support to Spring Boot project (java, flex, openjdk8, tomcat)

102 views
Skip to first unread message

Daniel Blazquez

unread,
Mar 22, 2019, 12:23:13 PM3/22/19
to Google App Engine

Hi,

I have been building an app on top of the helloworld-springboot tutorial. It is working great for APIs, but I wanted to add JSP support to include a simple admin console.

So I modified the helloworld-springboot project as following:
  1. Built a WEB-INF structure under src/main/webapp, including a jsp directory
  2. Modified application.properties to add spring.mvc.view.prefix and spring.mvc.view.suffix configuration that points to the directories in (1)
  3. Added dependencies to the pom.xml file for tomcat and jstl
<dependency>
   
<groupId>org.apache.tomcat.embed</groupId>
   
<artifactId>tomcat-embed-jasper</artifactId>
   
<version>9.0.12</version>
</dependency>
<dependency>
   
<groupId>javax.servlet</groupId>
   
<artifactId>jstl</artifactId>
   
<version>1.2</version>
</dependency>

 
4. Added a new @controller to SpringBoot, with the corresponding @GetMapping(s)
 
Running locally with mvn spring-boot:run works great, including JSP rendering, redirections, etc.

Now, when I deploy to GAE flex using the following yaml, the JSP fails to render with:

/WEB-INF/jsp/foo.jsp 404 not found

runtime: java
env
: flex

runtime_config
:  # Optional
  jdk
: openjdk8

manual_scaling
:
  instances
: 1

resources
:
  cpu
: 1
  memory_gb
: 2
  disk_size_gb
: 10


My questions are:
  • Can you help me understand why JSP works locally but not deployed on GAE? Is there any scope directive I am missing in the pom for the tomcat-embed-jasper dependency?
  • Do I need to use Jetty runtime to compile and render JSPs? I would much rather use the standard spring boot embedded tomcat
  • Do I need a web.xml with Tomcat? (I don't think that is the case)
  • Does it matter selecting JAR vs. WAR as packaging?
Thanks in advance,
Daniel

yka...@google.com

unread,
Apr 9, 2019, 10:11:44 AM4/9/19
to google-a...@googlegroups.com
Hello Daniel,

I recommend posting the full error you are getting along with the other questions on Stackoverflow as it is more suited for technical questions related to development and will have better visibility. Google Groups is better suited for high-level conceptual and general discussions about Google Cloud products.
Reply all
Reply to author
Forward
0 new messages