I'm trying to deserialize XML.
<server>
<url>localhost</url>
<port>8080</port>
</server>
to POJO
class Storage {
private Server server;
}
class Server {
private String url;
private Integer port;
}
Here is my fire code
resources = new FileInputStream("/resources/config/" + file);
mapper = new ObjectMapper();
storage = mapper.readValue(resources, Storage.class);
But it doesn't work.
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
I tried to add JAX-B annotation to Storage and Server class, but the same error occurred.
UPD
When I add mapper = new XmlMapper();
that I recieve com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "url"