Spring Boot 1.5.9和嵌入式jetty服务器在运行时抛出空指针异常?

时间:2017-12-29 16:19:26

标签: spring-boot nullpointerexception jetty

我正在将springboot应用程序更新为1.5.9,并且我遇到了嵌入了jetty服务器的以下运行时(nullpointer)异常:

Caused by: java.lang.NullPointerException
    at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:207) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:139) ~[jetty-servlet-9.4.7.v20170914.jar:9.4.7.v20170914]
    at org.eclipse.jetty.sNullPointerExceptionervlet.ServletHandler.initialize(ServletHandler.java:741) ~[jetty-servlet-9.4.7.v20170914.jar:9.4.7.v20170914]
    at org.springframework.boot.context.embedded.jetty.JettyEmbeddedWebAppContext$JettyEmbeddedServletHandler.deferredInitialize(JettyEmbeddedWebAppContext.java:46) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.context.embedded.jetty.JettyEmbeddedWebAppContext.deferredInitialize(JettyEmbeddedWebAppContext.java:36) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainer.handleDeferredInitialize(JettyEmbeddedServletContainer.java:205) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainer.handleDeferredInitialize(JettyEmbeddedServletContainer.java:211) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainer.start(JettyEmbeddedServletContainer.java:138) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]

它在spring boot 1.4.0中运行良好,所以问题肯定与升级到1.5.9?

有关

我在pom.xml中有以下内容:

<dependency>                                                                     
        <groupId>org.springframework.boot</groupId>                                  
        <artifactId>spring-boot-starter-web</artifactId>                             
        <version>1.5.9.RELEASE</version>                                    
        <exclusions>                                                                 
            <exclusion>                                                              
                <groupId>org.springframework.boot</groupId>                          
                <artifactId>spring-boot-starter-tomcat</artifactId>                  
            </exclusion>                                                             
        </exclusions>                                                                
    </dependency>                                                                    
    <dependency>                                                                     
        <groupId>org.springframework.boot</groupId>                                  
        <artifactId>spring-boot-starter-jetty</artifactId>                           
      <version>1.5.9.RELEASE</version>                                    
    </dependency>

由于

1 个答案:

答案 0 :(得分:0)

这对我来说很好,你可以删除你的缓存(.m2文件夹)尝试再次构建项目可能是缓存问题

这是我的POM

<?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.stackflow.test</groupId>
<artifactId>DemoSpring1.5.9</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>DemoSpring1.5.9</name>
<description>Stackflow project for Spring Boot</description>

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

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