org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException in REST with Spring

后端 未结 4 1305
无人共我
无人共我 2021-01-06 19:04

I am trying to create REST service using Spring.When I try to access that service it returns proper data but shows -

Exception handling request to /RESTServ         


        
4条回答
  •  遥遥无期
    2021-01-06 19:34

    We faced this issue while trial to migrate spring-boot-1.2.2-Final on wildfly 8.1.0-Final to spring-boot-1.3.2-Final on wildfly 8.1.0-Final. This error does not occur on wildfly 8.2.1-Final, so if you have option tp udate your wildfly version, you should do that.

    But if you still have to use wildfly-8.1.0-Final, then you could patch it.

    1) get https://github.com/undertow-io/undertow/archive/1.0.15.Final.zip

    2) edit io.undertow.servlet.spec.HttpServletResponseImpl located in module servlet

    @Override
    public String getHeaders(final String name) {
        return new ArrayList(exchange.getResponseHeaders().get(name));
    }
    

    to

    @Override
    public Collection getHeaders(final String name) {
        final HeaderValues headerValues = exchange.getResponseHeaders().get(name);
        if (headerValues != null) {
            return new ArrayList(headerValues);
        }
        return new ArrayList();
    }
    

    Add the HeaderValues import:

    import io.undertow.util.HeaderValues;
    

    package undertow-servlet with maven and then overwrite

    {wildfly-root-directory}/modules/system/layers/base/io/undertow/servlet/main/undertow-servlet-1.0.15.Final.jar

    with the file

    {undertow-root-directory}/servlet/target/undertow-servlet-1.0.15.Final.jar

    This will solve this error.

提交回复
热议问题