The type org.codehaus.jackson.JsonGenerationException cannot be resolved. It is indirectly referenced from required .class files

32,855

Solution 1

Make sure that the JAR containing org.codehaus.jackson.JsonGenerationException is on your classpath, e.g., by using jackson-core-asl POM.

Solution 2

import org.codehaus.jackson.map.ObjectMapper;

and also,you have to add jackson-core-asl-XXX.jar to build path.

Share:
32,855
blue-sky
Author by

blue-sky

scala :: java

Updated on October 22, 2020

Comments

  • blue-sky
    blue-sky over 3 years

    Using this code :

    import org.codehaus.jackson.map.ObjectMapper;
    ObjectMapper objectMapper = new ObjectMapper();
    String str = objectMapper.writeValueAsString(myObject);
    

    I receive this Eclipse error:

    The type org.codehaus.jackson.JsonGenerationException cannot be resolved. It is indirectly referenced from 
     required .class files
    

    at line String str = objectMapper.writeValueAsString(myObject);

    There are three 'JsonGenerationException' class types on my class path (you may have to save the image and open it separately to read the text in the image):

    enter image description here

    Is the reason I'm receiving this error message because JsonGenerationException is in two different jar files and Eclipse is unsure which on to use ? If so how can I fix it ?

    I required this jar file : http://grepcode.com/snapshot/repo1.maven.org/maven2/org.codehaus.jackson/jackson-core-asl/1.9.4