Reyjohn
Reyjohn

Reputation: 2734

The type com.fasterxml.jackson.core.JsonGenerator cannot be resolved. It is indirectly referenced from required .class files

Here I am using Jackson data binder 2.4.1 jar library in my eclipse project to convert an object to a json format. And here is my code:

ObjectMapper mapper = new ObjectMapper();
DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
mapper.writeValue(wr, content);

but in the last line mapper.writeValue(wr, content); it gives an error saying

The type com.fasterxml.jackson.core.JsonGenerator cannot be resolved. It is indirectly referenced from required .class files

I have studied and found that when a jar file's class is dependent on another class which is unavailable then this type of error occurs. But from where I am using this code snippet there is no issue like this. But I have failed a lot of time by changing the JAR version but nothing solved this issue. How can I solve this, please help

Upvotes: 16

Views: 45037

Answers (2)

Shehana Iqbal
Shehana Iqbal

Reputation: 37

Add jackson-core to your classpath in addition to jackson-databind.

Steps :

  1. Download jackson-core JAR file from here
  2. Right click on the project and go to properties > Build path > Libraries > classpath
  3. Select 'Add external JARs'
  4. Choose the file location
  5. Click on 'Apply and close'.

Upvotes: -1

Sotirios Delimanolis
Sotirios Delimanolis

Reputation: 279920

You need both jackson-databind and jackson-core on your classpath.

Upvotes: 51

Related Questions