Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot: Deploy WAR on Tomcat 7

I have developed a webapp with Spring Boot and generated the WAR. I have followed this instructions before generate the war. I'm deploying it in a Tomcat 7.0.52 but I get this:

INFO: validateJarFile(/opt/devel/server/apache-tomcat-7.0.52/webapps/myapp/WEB-INF/lib/tomcat-embed-el-8.0.32.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class 2016-04-19 11:48:28.579 WARN 27983 --- [io-8080-exec-14] org.apache.catalina.deploy.WebXml : Unknown version string [3.1]. Default version will be used.

I thought it was due to servlet spec version, but in the link above says that it supports 3.0 as well as 3.1 (Tomcat 8). If I deploy my app in a Tomcat 8, everything works.

Thanks.

like image 487
Héctor Avatar asked Apr 19 '16 10:04

Héctor


People also ask

Can we deploy WAR file in spring boot?

React + Spring Boot Microservices and SpringBy using Spring Boot application, we can create a war file to deploy into the web server. In this chapter, you are going to learn how to create a WAR file and deploy the Spring Boot application in Tomcat web server.

Can we deploy WAR file in Tomcat?

Perhaps the simplest way to deploy a WAR file to Tomcat is to copy the file to Tomcat's webapps directory. Copy and paste WAR files into Tomcat's webapps directory to deploy them. Tomcat monitors this webapps directory for changes, and if it finds a new file there, it will attempt to deploy it.

Can I deploy spring boot jar to Tomcat?

You can not deploy Jar to tomcat and expect it to load your web application. War has its own directory and file structure defined which is read by tomcat and load the application accordingly. It can not understand jar file as web application and run it.


1 Answers

As M. Deinum mentioned, Tomcat 7 is using 3.0.x servet APIs. Spring Boot by default uses 3.1. To change it, Spring Boot understands these Maven properties if you are using older servlet and tomcat APIs:

<properties>
    <tomcat.version>7.0.69</tomcat.version>
    <servlet-api.version>3.0.1</servlet-api.version>
</properties>
like image 99
luboskrnac Avatar answered Oct 05 '22 16:10

luboskrnac