Tuesday, 7 October 2014

FasterXML: Could not deserialize form XML to POJO



I'm trying to deserialize XML.



<server>
<uri>localhost</uri>
<port>8080</port>
</server>


to POJO



class Storage {
private Server server;
}

class Server {
private Server 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.


No comments:

Post a Comment