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

this is an issue with WildFly - 8.1 you have to use WildFly - 8.2 or use Jboss 7.

Ingvar Evaldsson

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<String>(exchange.getResponseHeaders().get(name));
}

to

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

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.

If your are using maven, add JSON Databinding dependencies specified below in your pom.xml and annotate the User class with @JsonRootName(value = "user"),

    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-jaxrs</artifactId>
        <version>1.9.13</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-xc</artifactId>
        <version>1.9.13</version>
    </dependency>

This may be helpful to those who aren't able to upgrade past Wildfly 8.1.0 in their project to address this problem. Ingvar's answer above of patching the code helped me out a lot, and here is a script that will perform the patch in one command for you (keeping a backup of your previous copy):

https://github.com/ldojo/wf-8.1.0-undertow-1.0.15-patch