I am trying to convert a Json String to a HashMap but it is not working.
My code:
ObjectMapper mapper = new ObjectMapper();
Map<String,Object> map = mapper.readValue("Json String placeholder", Map.class);
I get the following exception:
java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonAutoDetect
at com.fasterxml.jackson.databind.introspect.VisibilityChecker$Std.<clinit>(VisibilityChecker.java:172)
at com.fasterxml.jackson.databind.ObjectMapper.<clinit>(ObjectMapper.java:195)
.....
What am I doing wrong? Is there another possibility to convert it? Or is anything missing?
NoClassDefFoundErroris not specific to your particular use with JSON but occurs if a class that was available at compile time cannot be found by JVM at runtime. How can that happen? Most frequently it happens if your compilationclasspathis different from your execution one. I have seen it happen withanta lot. Make sure the pertinent jar is included in the execution classpath.