Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 639
blue-sky Avatar asked Dec 06 '12 22:12

blue-sky


2 Answers

import org.codehaus.jackson.map.ObjectMapper;

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

like image 33
hiallen Avatar answered Sep 22 '22 02:09

hiallen


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

like image 112
reprogrammer Avatar answered Sep 19 '22 02:09

reprogrammer