1

here is my code. I've added all the dependencies then also getting such error. google-http-client-jackson2-1.17.0-rc.jar

here in this code in getting above mentioned error at JsonFactory jsonFactory = new JacksonFactory();

import com.google.api.services.customsearch.Customsearch; import com.google.api.services.customsearch.model.Search; import com.google.api.services.customsearch.model.Result; import com.google.api.client.http.HttpRequestInitializer; import com.google.api.client.http.HttpRequest; import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.JsonFactory; import com.google.api.client.json.jackson2.JacksonFactory; protected SearchResult[] doSearch() { HttpRequestInitializer httpRequestInitializer = new HttpRequestInitializer() { @Override public void initialize(HttpRequest request) throws IOException { } }; JsonFactory jsonFactory = new JacksonFactory(); Customsearch csearch = new Customsearch( new NetHttpTransport(), jsonFactory, httpRequestInitializer); Customsearch.Cse.List listReqst; try { listReqst = csearch.cse().list(query.getQueryString()); listReqst.setKey(GOOGLE_KEY); // set the search engine ID got from API console listReqst.setCx("search engine ID"); // set the query string listReqst.setQ(query.getQueryString()); // language chosen is English for search results listReqst.setLr("lang_en"); // set hit position of first search result listReqst.setStart((long) firstResult); // set max number of search results to return listReqst.setNum((long) maxResults); //performs search Search result = listReqst.execute(); java.util.List<Result> results = result.getItems(); String urls[] = new String [result.size()]; String snippets[] = new String [result.size()]; int i=0; for (Result r : results){ urls[i] = r.getLink(); snippets[i] = r.getSnippet(); i++; } return getResults(snippets, urls, true); } catch (IOException e) { // TODO Auto-generated catch block MsgPrinter.printSearchError(e); System.exit(1); return null; } } 

kindly suggest me how it should be fixed.

8
  • Show us your imports please. Commented Apr 2, 2014 at 18:08
  • import com.google.api.services.customsearch.Customsearch; import com.google.api.services.customsearch.model.Search; import com.google.api.services.customsearch.model.Result; import com.google.api.client.http.HttpRequestInitializer; import com.google.api.client.http.HttpRequest; import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.JsonFactory; import com.google.api.client.json.jackson2.JacksonFactory; Commented Apr 2, 2014 at 18:12
  • You're getting this at run time, right? What's your class path when you run this? Commented Apr 2, 2014 at 18:27
  • 1
    You are missing com.fasterxml.jackson.core:jackson-core dependency. central.maven.org/maven2/com/fasterxml/jackson/core/… Commented Apr 2, 2014 at 18:32
  • 1
    Add jackson-core as well ;). Commented Apr 2, 2014 at 18:38

4 Answers 4

1

To answer the question directly (it was answered in the comments by Pavel). The jackson core lib dependency was missing: jackson-core-$x.y.z.jar

Sign up to request clarification or add additional context in comments.

Comments

1

Happened to me when having 2 jackson versions - codehaus vs. fasterlxml. Removing the fasterxml version (that was a trans-dependency of swagger) fixed the issue.

<dependency> <groupId>io.swagger</groupId> <artifactId>swagger-jersey-jaxrs</artifactId> <version>1.5.3</version> <exclusions> <exclusion> <groupId>javax.ws.rs</groupId> <artifactId>jsr311-api</artifactId> </exclusion> <exclusion> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> </exclusion> <exclusion> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> </exclusion> <exclusion> <groupId>com.fasterxml.jackson.jaxrs</groupId> <artifactId>jackson-jaxrs-json-provider</artifactId> </exclusion> <!--<exclusion>--> <!--<groupId>com.fasterxml.jackson.datatype</groupId>--> <!--<artifactId>jackson-datatype-joda</artifactId>--> <!-- test --> </exclusions> </dependency> 

Comments

0

I had a similar problem, eventually discovered it was an issue with the buildpath and dependencies. The easiest (not most efficient) is too add all the google-api-client jars to your project and it would disappear. Better way is to track and properly add all other dependencies of jacksonFactory

Comments

0

Down load the Maven of jackson from here.

Then add it to your dependencies.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.