0

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

enter image description here

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?

bunT
  • 73
  • 1
  • 1
  • 7
  • Look into tomcat logfiles for more informations – Jens Oct 06 '20 at 06:08
  • Please add the complete stack trace and the controller code that provides /onlineshopping. – Milgo Oct 06 '20 at 06:08
  • @Milgo I added log file of tomcat it is something to do with web.xml file – bunT Oct 06 '20 at 06:18
  • my web.xml file is blank. – bunT Oct 06 '20 at 06:25
  • [This](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file) will probably solve your problem. – neofelis Oct 06 '20 at 07:23
  • @neofelis i solved most of the problems from logs. now i am stuck at -- registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. – bunT Oct 06 '20 at 12:50
  • i solved this issue by this https://stackoverflow.com/questions/25699985/the-web-application-appears-to-have-started-a-thread-named-abandoned-connect/26261752 – bunT Oct 06 '20 at 14:42
  • My app is successfully started. – bunT Oct 06 '20 at 14:43

0 Answers0