maven - Google Vision Batch Annotate Images with Java Client Library -


i getting exception when trying annotate images via google vision using provided java client google vision.

specifically code batch client.batchannotateimages occurs:

public void processocr(byte[] file)  {      list<annotateimagerequest> requests = new arraylist<>();        bytestring imagebytestring = bytestring.copyfrom(file);        image img = image.newbuilder().setcontent(imagebytestring).build();       feature feat = feature.newbuilder().settype(type.document_text_detection).build();        annotateimagerequest request = annotateimagerequest.newbuilder().addfeatures(feat).setimage(img).build();       requests.add(request);        try (imageannotatorclient client = imageannotatorclient.create())        {          batchannotateimagesresponse response = client.batchannotateimages(requests);         list<annotateimageresponse> responses = response.getresponseslist();         client.close();          //visionresultsdto result = new visionresultsdto();         string paragraphtext = "";           (annotateimageresponse res : responses) {           if (res.haserror()) {             //throw exception.             return;           }            // full list of available annotations, see http://g.co/cloud/vision/docs           textannotation annotation = res.getfulltextannotation();           (page page: annotation.getpageslist()) {             string pagetext = "";             (block block : page.getblockslist()) {           string blocktext = "";               (paragraph para : block.getparagraphslist()) {                 string paratext = "";                 (word word: para.getwordslist()) {                   string wordtext = "";               (symbol symbol: word.getsymbolslist()) {                     wordtext = wordtext + symbol.gettext();                   }               paratext = paratext + wordtext;                 }                 // output example using paragraph:                 blocktext = blocktext + paratext;               }               pagetext = pagetext + blocktext;             }           }           paragraphtext = annotation.gettext();         //  result.setresulttext(paragraphtext);         }       } catch (exception e)        {         // todo auto-generated catch block         e.printstacktrace();        }  } 

i being presented following stack trace / error:

java.lang.nosuchmethoderror: com.google.common.util.concurrent.moreexecutors.directexecutor()ljava/util/concurrent/executor; @ com.google.api.gax.retrying.basicretryingfuture.(basicretryingfuture.java:77) @ com.google.api.gax.retrying.callbackchainretryingfuture.(callbackchainretryingfuture.java:62) @ com.google.api.gax.retrying.scheduledretryingexecutor.createfuture(scheduledretryingexecutor.java:86) @ com.google.api.gax.grpc.retryingcallable.futurecall(retryingcallable.java:57) @ com.google.api.gax.grpc.retryingcallable.futurecall(retryingcallable.java:42) @ com.google.api.gax.grpc.authcallable.futurecall(authcallable.java:57) @ com.google.api.gax.grpc.unarycallable.futurecall(unarycallable.java:282) @ com.google.api.gax.grpc.unarycallable.futurecall(unarycallable.java:293) @ com.google.api.gax.grpc.unarycallable.call(unarycallable.java:321) @ com.google.cloud.vision.v1.imageannotatorclient.batchannotateimages(imageannotatorclient.java:201) @ com.google.cloud.vision.v1.imageannotatorclient.batchannotateimages(imageannotatorclient.java:177) @ za.co.thumbtribe.core.googlevision.service.impl.googlevisionserviceimpl.processocr(googlevisionserviceimpl.java:55)

here pom dependencies :

<dependencies> <!-- spring --> <dependency>   <groupid>org.springframework</groupid>   <artifactid>spring-web</artifactid>   <version>4.2.5.release</version>   <scope>compile</scope> </dependency> <dependency>     <groupid>com.google.cloud</groupid>     <artifactid>google-cloud-vision</artifactid>     <version>0.20.3-beta</version>     <exclusions>     <exclusion>       <groupid>com.google.auth</groupid>       <artifactid>google-auth-library-oauth2-http</artifactid>     </exclusion>     <exclusion>       <groupid>com.google.auth</groupid>       <artifactid>google-auth-library-credentials</artifactid>     </exclusion>   <exclusion>     <groupid>com.google.guava</groupid>     <artifactid>*</artifactid> </exclusion>   </exclusions> </dependency> <dependency>   <groupid>com.google.auth</groupid>   <artifactid>google-auth-library-oauth2-http</artifactid>   <version>0.7.0</version>  </dependency>  <dependency>   <groupid>com.google.auth</groupid>   <artifactid>google-auth-library-credentials</artifactid>   <version>0.7.0</version> </dependency>  </dependencies> 

i have tried excluding guava , including multiple versions of api.

the code shown sample code google vision client implementation.

any ideas ?

the missing method directexecutor in moreexecutors class annotated @since 18.0 in sources of guava (see source).

i guess have in classpath older version of guava appears before version 19.

you should run mvn dependency:analyze track down culprit. may mvn dependency:analyze | grep guava filter output.

then can check package imports old dependency :

mvn dependency:tree -dverbose


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -