I am trying to deploy spring boot app war file on tomcat. I successfully created war file of spring boot app. But whenever I tried to deploy war file on tomcat it is not starting and gives message - FAIL - Application at context path [/onlineshopping] could not be started
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.springboot</groupId>
<artifactId>wabit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>wabit</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>onlineshopping</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
application.properties
server.port=8083
server.servlet.context-path=/onlineshopping
SecurityConfig.java
@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Arrays.asList("http://localhost:4200"));
configuration.setAllowedOrigins(Arrays.asList("http://localhost:8080"));
configuration.setAllowCredentials(true);
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"));
configuration.setAllowedHeaders(Arrays.asList("Access-Control-Allow-Origin","Authorization", "Cache-Control", "Content-Type", "xsrfheadername","xsrfcookiename"
,"X-Requested-With","XSRF-TOKEN","Accept", "x-xsrf-token","withcredentials","x-csrftoken"));
configuration.setExposedHeaders(Arrays.asList("custom-header1", "custom-header2"));
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
Controller.java
@RequestMapping(value = "/clientProducts/products/{start}")
public Stack<List> getAllCLientproduct(@PathVariable int start) {
List<ClientProducts> clientProductsinfo =
productDAO.getAllCLientproducts(start);
List<List<ClientProducts>> strings = Arrays.asList(clientProductsinfo);
Stack<List> STACK = new Stack<List>();
STACK.push( clientProductsinfo);
return STACK;
}
Tomcat Logs
org.apache.tomcat.util.descriptor.web.WebXmlParser.parseWebXml Parse
error in application web.
xml file at[file:/C:/Program%20F iles/Apache%20 Software%20F
oundation/Tomcat%209.0/webapps/onlineshopping/WEB-
INF/web.xml]org.xml.sax.SAXParseException;systemId:file:/C:/Program%20F
iles/Apache%20 Software%20F
oundation/Tomcat%209.0/webapps/onlineshopping/WEB-
INF/web.xml;lineNumber:53;columnNumber:15;
Premature end of file.
FAIL - Application at context path [/onlineshopping] could not be started. This message is because of context path and port no I provided in application properties?