2017-08-26 1 views
0

J'essaie simplement de lister le contenu de mon seau Google Cloud Storage de mon GAE (java) en utilisant le code suivant:Google Cloud Storage Erreur d'exécution

GcsService gcsService = GcsServiceFactory.createGcsService(new RetryParams.Builder() 
         .initialRetryDelayMillis(10) 
         .retryMaxAttempts(10) 
         .totalRetryPeriodMillis(15000) 
         .build()); 

try{ 
    ListResult list = gcsService.list("MyTestBucket", new ListOptions.Builder().setPrefix("testFolder").setRecursive(true).build()); 
    } 

Il compile, mais quand je le lance, je l'erreur suivante que je ne comprends pas:

Caused by: java.lang.NoSuchMethodError: com.google.appengine.tools.cloudstorage.GcsService.list(Ljava/lang/String;Lcom/google/appengine/tools/cloudstorage/ListOptions;)Lcom/google/appengine/tools/cloudstorage/ListResult; 

la dépendance POM ressemble à ceci pour inclure Google Storage:

<dependency> 
    <groupId>com.google.appengine.tools</groupId> 
    <artifactId>appengine-gcs-client</artifactId> 
    <version>0.6</version> 
</dependency> 

J'ai essayé divers <exclusions> mais n'arrive pas à le faire fonctionner. Merci Tim

POM fichier:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 

<modelVersion>4.0.0</modelVersion> 
<packaging>war</packaging> 
<version>1.0</version> 

<groupId>com.xyz.abc</groupId> 
<artifactId>xyzclienttest</artifactId> 

<properties> 
    <appengine.app.version>1</appengine.app.version> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

<prerequisites> 
    <maven>3.1.0</maven> 
</prerequisites> 

<dependencies> 
    <!-- Compile/runtime dependencies --> 
    <dependency> 
     <groupId>com.google.appengine</groupId> 
     <artifactId>appengine-api-1.0-sdk</artifactId> 
     <version>1.9.54</version> 
    </dependency> 

    <dependency> 
     <groupId>com.google.appengine.tools</groupId> 
     <artifactId>appengine-gcs-client</artifactId> 
     <version>0.6</version> 
    </dependency> 

    <dependency> 
     <groupId>org.glassfish.jersey.containers</groupId> 
     <artifactId>jersey-container-servlet-core</artifactId> 
     <version>2.17</version> 
    </dependency> 
    <dependency> 
     <groupId>org.glassfish.jersey.media</groupId> 
     <artifactId>jersey-media-moxy</artifactId> 
     <version>2.17</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-codec</groupId> 
     <artifactId>commons-codec</artifactId> 
     <version>1.10</version> 
    </dependency> 
    <dependency> 
     <groupId>com.googlecode.objectify</groupId> 
     <artifactId>objectify</artifactId> 
     <version>5.1.5</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>servlet-api</artifactId> 
     <version>2.5</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>javax.inject</groupId> 
     <artifactId>javax.inject</artifactId> 
     <version>1</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.jdo</groupId> 
     <artifactId>jdo-api</artifactId> 
     <version>3.1</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.code.gson</groupId> 
     <artifactId>gson</artifactId> 
     <version>2.3.1</version> 
    </dependency> 
    <dependency> 
     <groupId>com.github.mpkorstanje</groupId> 
     <artifactId>simmetrics-core</artifactId> 
     <version>3.2.3</version> 
    </dependency> 

</dependencies> 

<build>  <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory> 
    <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>versions-maven-plugin</artifactId> 
      <version>2.1</version> 
      <executions> 
       <execution> 
        <phase>compile</phase> 
        <goals> 
         <goal>display-dependency-updates</goal> 
         <goal>display-plugin-updates</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.5.1</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
       <encoding>UTF-8</encoding> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.6</version> 
     </plugin> 
     <plugin> 
      <groupId>com.google.appengine</groupId> 
      <artifactId>appengine-maven-plugin</artifactId> 
      <version>1.9.54</version> 
      <configuration> 
       <enableJarClasses>false</enableJarClasses> 
       <!-- Comment in the below snippet to bind to all IPs instead of just localhost --> 
       <!-- address>0.0.0.0</address> 
       <port>8080</port --> 
       <!-- Comment in the below snippet to enable local debugging with a remove debugger 
        like those included with Eclipse or IntelliJ --> 
       <!-- jvmFlags> 
        <jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag> 
       </jvmFlags --> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

<reporting> 
    <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>findbugs-maven-plugin</artifactId> 
      <configuration> 
       <!-- 
        Enables analysis which takes more memory but finds more bugs. 
        If you run out of memory, changes the value of the effort element 
        to 'low'. 
       --> 
       <effort>Max</effort> 
       <!-- Reports all bugs (other values are medium and max) --> 
       <threshold>Low</threshold> 
       <onlyAnalyze>com.xyz.abc.*,com.xyz.abc.util.*</onlyAnalyze> 
       <!-- Produces XML report --> 
       <xmlOutput>true</xmlOutput> 
       <xmlOutputDirectory>target/site</xmlOutputDirectory> 
      </configuration> 
     </plugin>  
    </plugins> 
</reporting> 

+0

Pouvez-vous partager le fichier POM complet? Peut-être qu'il y a quelque chose d'autre (par exemple, l'observation) – David

+0

Ajouté le fichier POM complet au message original. –

Répondre

1

Correction du problème! J'ai regardé dans le fichier .war et j'ai trouvé qu'il y avait deux versions des fichiers jar appengine-gcs-client. 0,2 et 0,6. J'ai fait un mvn propre et cela a réglé le problème. J'aurais vraiment dû faire cela avant :-(Live and learn!

0

Essayez de supprimer <enableJarClasses>false</enableJarClasses>. Je suspecte que cela provoque l'inclusion du fichier JAR pour la bibliothèque GCS dans l'artefact exécuté sur GAE. Par conséquent, les classes requises peuvent être manquantes.

+0

Merci, mais cela ne semble pas faire de différence: faut-il ajouter des exceptions aux autres dépendances? –