Unexpected NullPointerException When Parsing XML with Jackson XML in Spring Boot
I've searched everywhere and can't find a clear answer... I'm working with a `NullPointerException` while trying to deserialize an XML response using Jackson XML in my Spring Boot application. My XML structure looks like this: ```xml <response> <data> <item> <id>1</id> <name>Item 1</name> </item> <item> <id>2</id> <name>Item 2</name> </item> </data> </response> ``` I've created the following classes to map the XML: ```java import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import java.util.List; public class Response { @JacksonXmlProperty(localName = "data") private Data data; // Getters and setters } public class Data { @JacksonXmlProperty(localName = "item") private List<Item> items; // Getters and setters } public class Item { private int id; private String name; // Getters and setters } ``` When I try to deserialize the XML using the following code: ```java import com.fasterxml.jackson.dataformat.xml.XmlMapper; XmlMapper xmlMapper = new XmlMapper(); Response response = xmlMapper.readValue(xmlString, Response.class); ``` I receive this stack trace: ``` java.lang.NullPointerException at my.package.Response.getData(Response.java:10) at my.package.XmlProcessingService.processResponse(XmlProcessingService.java:25) ``` I've ensured that the XML string is properly formed and have tested with various inputs. However, if I change the `List<Item>` to `Item[]` in the `Data` class, the `NullPointerException` goes away, but then I need to easily work with the list. I also tried adding the `@JacksonXmlElementWrapper(useWrapping = false)` annotation to the `items` field, but that didn't help either. Any insight into why I'm seeing this behavior and how to properly deserialize the XML into a List without getting a NullPointerException? I'm using Jackson XML version 2.12.3 and Spring Boot version 2.5.4. What am I doing wrong?