Spring-boot: Spring Boot 2.0.0.RELEASE cannot boot successfully with spring-boot-starter-web

Created on 8 Mar 2018  路  10Comments  路  Source: spring-projects/spring-boot

My enviroment: win10, STS-3.9.2.RELEASE
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.hz</groupId>
    <artifactId>springmvctest1</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>springmvctest1</name>
    <description>test1</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.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</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

when I right click on my project and select "Run As", and then click Spring Boot App, it runs failed with logs:

2018-03-08 13:53:25.302  INFO 11172 --- [           main] com.hz.Springmvctest1Application         : Starting Springmvctest1Application on hxwmd with PID 11172 (E:\files\sts-3.9.2.RELEASE\springmvctest1\target\classes started by xiao01wei in E:\files\sts-3.9.2.RELEASE\springmvctest1)
2018-03-08 13:53:25.305  INFO 11172 --- [           main] com.hz.Springmvctest1Application         : No active profile set, falling back to default profiles: default
2018-03-08 13:53:25.326  INFO 11172 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2ef3eef9: startup date [Thu Mar 08 13:53:25 CST 2018]; root of context hierarchy
2018-03-08 13:53:25.410  WARN 11172 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
2018-03-08 13:53:25.425 ERROR 11172 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at com.hz.Springmvctest1Application.main(Springmvctest1Application.java:11) [classes/:na]
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:204) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:178) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    ... 8 common frames omitted

I comment the dependency "spring-boot-starter-web", and the project start normally.
And another try is I change the version "2.0.0.RELEASE" to "1.5.10.RELEASE", the web project starts normally.

invalid

Most helpful comment

You have a corrupted jar in Maven鈥檚 cache. Try running mvn dependency:purge-local-repository or deleting the cache and then start your application again.

All 10 comments

You have a corrupted jar in Maven鈥檚 cache. Try running mvn dependency:purge-local-repository or deleting the cache and then start your application again.

I close my ide(sts-3.9.2-release) and use git bash, cd to my project dir and then execute command "mvn dependency:purge-local-repository", spring-boot-starter[-web//-test]-2.0.0.RELEASE is redownloaded from "https://repo.spring.io/milestone". But when I open my ide and boot as "Spring Boot App", the errors are still remaining.
Not working too as I use "eclipse-jee-oxygen-1a-win32-x86_64".

I've just noticed that your pom doesn't even depend on spring-boot-starter-web so it seems unlikely that Maven would download it or that your application would be a web application. If you'd like us to re-open this and spend some more time trying to help you, please spend some time to produce a minimal, complete, and verifiable example of the problem.

I am so sorry that I paste my code after commenting/deleting the dependency of "spring-boot-starter-web". By the way, jdk1.8.0-162(x64) is used.
Finally, there is the content of pom.xml now:


xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0

<groupId>com.hz</groupId>
<artifactId>springmvctest1</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>springmvctest1</name>
<description>test1</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.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</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

@xiao911wei There's nothing obviously wrong with your POM file. A corrupt jar still seems like the most likely issue. Is your IDE setup to use a different local maven repo? Does mvn dependency:purge-local-repository followed by mvn spring-boot:run give the same error (or is it only in the IDE)?

The command "mvn dependency:purge-local-repository" and "mvn spring-boot:run" are not working.
Finally I solve this problem by myself, there is my step:

  1. change repo/mirror in /conf/settings.xml to default, and exec these 2 commands again:
    ------still not woring, just the same error(only a few running exception)
    ....
  2. download a simple demo from "https://start.spring.io", just add "web" dependency and download this demo
  3. unzip demo.zip, run cmd and enter demo dir
  4. exec "mvn dependency:purge-local-repository" and "mvn spring-boot:run", and I find an exception like this ".....repositoryorgspringframeworkbootspring-boot-autoconfigure2.0.0.RELEASEspring-boot-autoconfigure-2.0.0.RELEASE.jar....invalid LOC header (bad signature)"
  5. delete dir ".....repositoryorgspringframeworkbootspring-boot-autoconfigure2.0.0.RELEASE" manually and exec "mvn spring-boot:run" again, everything is OK.
    Finally, thank you guys. @wilkinsona @philwebb

it was due tomcat error ...tomcat 7 when tomcat 8.0.27 installed it was running.....the tomcat is given by ide itself in my case netbeans

it was due to corrupted repos only in my case too

The command "mvn dependency:purge-local-repository" and "mvn spring-boot:run" are not working.
Finally I solve this problem by myself, there is my step:

  1. change repo/mirror in /conf/settings.xml to default, and exec these 2 commands again:
    ------still not woring, just the same error(only a few running exception)
    ....
  2. download a simple demo from "https://start.spring.io", just add "web" dependency and download this demo
  3. unzip demo.zip, run cmd and enter demo dir
  4. exec "mvn dependency:purge-local-repository" and "mvn spring-boot:run", and I find an exception like this ".....repositoryorgspringframeworkbootspring-boot-autoconfigure2.0.0.RELEASEspring-boot-autoconfigure-2.0.0.RELEASE.jar....invalid LOC header (bad signature)"
  5. delete dir ".....repositoryorgspringframeworkbootspring-boot-autoconfigure2.0.0.RELEASE" manually and exec "mvn spring-boot:run" again, everything is OK.
    Finally, thank you guys. @wilkinsona @philwebb

maybe is the idea initialzr's fault , just add follow dependency to use correct tomcat version:

org.springframework.boot
spring-boot-starter-tomcat

it resolved

@YangZhuoNJ you have a totally different problem and it would be better to move your actual question to StackOverflow. You're probably have a war-based project and an older IJ version, see this question.

Was this page helpful?
0 / 5 - 0 ratings