embedded tomcat in spring does not take maven dependencies

48 views Asked by At

I have a spring boot 2 application which I am running on embedded tomcat in production. I want to add another war file to the same tomcat.

I followed spring boot 2 solution provided in link Spring Boot: How to add another WAR files to the embedded tomcat?

The other war file has some jsp elements. I followed the solution and added the dependencies such as

<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
</dependency>

I can see that they have been added in the dependencies section of my intellij. i have also used the below in my Bean

Context context = tomcat.addWebapp(contextPath, path);
 context.setParentClassLoader(getClass().getClassLoader());

but unfortunately my external war does not start and fails with exception

SEVERE:Servlet[jsp] in web application /test threw load exception
java.lang.ClassNotFoundException: org.apache.jasper.servlet.jspServlet

i assumed that tomcat-embed-jasper would have add japser servlet class, but it didn;t What dependencies should i add to embedded server to run this.

1

There are 1 answers

0
Seeker On

It was an issue with intellij. I invalidated the cache and restarted the IDE. it reloaded the indexes and after that everything was working.