简体   繁体   中英

google drive dredit error java.lang.NoSuchMethodError: com.google.api.client.http.HttpRequestFactory.buildRequest

Trying to run the Google drive sample I always get the error explained below. I checked the configuration and it looks correct. Last releases of appengine eclipse plugin is been used. The error thrown looks as if the method : com.google.api.client.http.HttpRequestFactory.buildRequest is not available at runtime. This is a deprecated method but no error is given at compile time. Has anybody encountered the same situation ?

012-12-16 08:52:01.050 Uncaught exception from servlet

    java.lang.NoSuchMethodError: com.google.api.client.http.HttpRequestFactory.buildRequest(Ljava/lang/String;Lcom/google/api/client/http/GenericUrl;Lcom/google/api/client/http/HttpContent;)Lcom/google/api/client/http/HttpRequest;
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequest(AbstractGoogleClientRequest.java:290)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:396)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:328)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:449)
    at it.contextsolutions.drived.CredentialMediator.getUserInfo(CredentialMediator.java:211)
    at it.contextsolutions.drived.CredentialMediator.getActiveCredential(CredentialMediator.java:312)
    at it.contextsolutions.drived.DrEditServlet.getCredentialMediator(DrEditServlet.java:98)
    at it.contextsolutions.drived.DrEditServlet.getClientId(DrEditServlet.java:143)
    at it.contextsolutions.drived.StartPageServlet.doGet(StartPageServlet.java:46)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)     
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)     
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    "

problem is in fact drEdit sample still has GAE 1.6.3 version libraries, and you added GAE API (and drive/oauth2 api) from newer version.

Just check sources of your project under web/WEB-INF/lib - you will have many dublications of same jars, but different versions:

  • appengine-api-xxx-1.6.3 (got from drEdit sources) and appengine-api-xxx-1.7.4 (added by Google plugin in Eclipse)
  • google-api-client-xxx-1.10.3-beta.jar (got from drEdit sources) and google-api-client-xxx-1.12.0-beta (added by Eclipse plugin)
  • google-api-services-xxx-1.7.2-beta (got from drEdit sources) and google-api-services-xxx-1.12.0-beta (added by Eclipse plugin).

Simple clean you web/WEB-INF/lib folder by removing old versions of jar - in my case it helped.

My way to make it work:

check out the google-drive-sdk-samples, copy it to your workspace, but delete all out-of-date libraries in WEB-INF/lib.

Add Drive-SDK and OAuth2 API, this will automatically add all required library files to WEB-INF/lib.

Now your library is consistent and you are good to go!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM