在Maven清理/构建和部署后,Java App Engine调用GcsService.createOrReplace导致Stopwatch.createUnstarted noSuchMethodError [英] Java App Engine call to GcsService.createOrReplace results in Stopwatch.createUnstarted noSuchMethodError after Maven clean/build and deploy

查看:232
本文介绍了在Maven清理/构建和部署后,Java App Engine调用GcsService.createOrReplace导致Stopwatch.createUnstarted noSuchMethodError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的GAE Java项目使用了Intellij和Maven。我从 createOrReplace 时遇到一些奇怪的问题/ appengine / tools / cloudstorage / GcsServicerel =nofollow noreferrer> Google Cloud Storage中的GcsService ,这取决于我在我的项目中编辑单个文件。这里发生了什么:



我在Github上有一个稳定的版本。我签出该修订并使用intellij配置来部署应用程序。我的部署看起来像这样: /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/bin/java -Dfile.encoding = UTF-8 -classpath /Users/me/.m2/repository/com/ google / appengine / appengine-java-sdk / 1.9.15 / appengine-java-sdk / appengine-java-sdk-1.9.15 / lib / appengine-tools-api.jar com.google.appengine.tools.admin.AppCfg --email=me@gmail.com --passin --no_cookies更新/Users/me/git/blunka/harry-gcp/module-ear/target/module-ear-1.0//code>



然后给特定的源文件添加评论。我重新部署了,并且我注意到 / target 下的一些输出文件已经改变。我的应用程序现在因此错误而中断:

  java.lang.NoSuchMethodError:com.google.common.base.Stopwatch.createUnstarted ()LCOM /谷歌/普通/碱/秒表; 
at com.google.appengine.tools.cloudstorage.RetryHelper.runWithRetries(RetryHelper.java:156)
at com.google.appengine.tools.cloudstorage.GcsServiceImpl.createOrReplace(GcsServiceImpl.java:70)

我现在删除该评论并再次部署。我做了一个 git status ,注意 / target 下的一些已更改的文件不再存在。我的应用程序再次正常工作。



当我查看已修改类的已反编译的.class文件时,它们是相同的。

  [信息] +  -  com.google.api-client :google-api-client-appengine:jar:1.19.0:编译
[INFO] | \- com.google.api-client:google-api-client:jar:1.19.0:compile
[INFO] | \- com.google.guava:guava-jdk5:jar:13.0:编译
[INFO] + - com.google.appengine.tools:appengine-gcs-client:jar:RELEASE:compile
[INFO] | \-(com.google.guava:guava:jar:18.0:编译 - 省略重复)
[INFO] + - com.google.guava:guava:jar:18.0:compile
[INFO ] \- com.googlecode.objectify:objectify:jar:5.1.1:编译
[INFO] \-(com.google.guava:guava:jar:17.0:compile - 在与18.0冲突时省略)

我有几个问题:


  1. 为什么评论会导致我的输出文件发生变化?

  2. 为什么从注释中更改输出文件会导致应用程序行为发生变化,即使反编译如果guava(google.common.base)发生冲突,我该如何解决它们?

  3. 如何防止某些东西这样的情况发生在未来?
  4. @ ben-manes在他的评论中是正确的。我有同样的问题,他最后的消息帮助了我。我只是想将它作为答案,因为不是每个人都会看到评论。



    google-api-client取决于guava-jdk5,它与guava- 18+,由appengine-gcs-client使用
    $ b

     < dependency> 
    < groupId> com.google.api-client< / groupId>
    < artifactId> google-api-client-appengine< / artifactId>
    < version> 1.20.0< / version>
    <排除项>
    <! - 与appengine-gcs-client中的另一个番石榴版本产生冲突 - >
    <排除>
    < groupId> com.google.guava< / groupId>
    < artifactId> guava-jdk5< / artifactId>
    < /排除>
    < /排除>
    < /依赖关系>


    I am using Intellij and Maven for my GAE Java project. I have some strange issues with calling createOrReplace from GcsService in Google Cloud Storage, that is dependent on me editing a single file in my project. Here is what happens:

    I have a stable revision on Github. I checkout that revision and use an intellij configuration to deploy the app. My deployment looks like this: After the clean install and build, this is the command that gets executed: /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -classpath /Users/me/.m2/repository/com/google/appengine/appengine-java-sdk/1.9.15/appengine-java-sdk/appengine-java-sdk-1.9.15/lib/appengine-tools-api.jar com.google.appengine.tools.admin.AppCfg --email=me@gmail.com --passin --no_cookies update /Users/me/git/blunka/harry-gcp/module-ear/target/module-ear-1.0

    I then add a comment to a specific source file. I redeploy and I notice a bunch of output files under /target have changed. My app is now broken with this error:

    java.lang.NoSuchMethodError: com.google.common.base.Stopwatch.createUnstarted()Lcom/google/common/base/Stopwatch;
        at com.google.appengine.tools.cloudstorage.RetryHelper.runWithRetries(RetryHelper.java:156)
        at com.google.appengine.tools.cloudstorage.GcsServiceImpl.createOrReplace(GcsServiceImpl.java:70)
    

    I now delete that comment and deploy again. I do a git status and notice that some of the changed files under /target are no longer there. My app works fine again.

    When I look at the decompiled .class files of the modified class, they are identical. Here is my dep tree for the module that is throwing the error:

    [INFO] +- com.google.api-client:google-api-client-appengine:jar:1.19.0:compile
    [INFO] |  \- com.google.api-client:google-api-client:jar:1.19.0:compile
    [INFO] |     \- com.google.guava:guava-jdk5:jar:13.0:compile
    [INFO] +- com.google.appengine.tools:appengine-gcs-client:jar:RELEASE:compile
    [INFO] |  \- (com.google.guava:guava:jar:18.0:compile - omitted for duplicate)
    [INFO] +- com.google.guava:guava:jar:18.0:compile
    [INFO] \- com.googlecode.objectify:objectify:jar:5.1.1:compile
    [INFO]    \- (com.google.guava:guava:jar:17.0:compile - omitted for conflict with 18.0)
    

    I have a few questions:

    1. Why does a comment cause my output files to change?
    2. Why do changed output files from a comment cause a change in behavior of the app, even though the decompiled source is the same?
    3. If guava (google.common.base) has collisions, how can I fix them?
    4. How can I prevent something like this from happening in the future?

    解决方案

    Sorry for "stealing" the answer, but @ben-manes is right in his comment. I had the same problem and his last message helped me. I just want to make this as an answer, because not everybody looks through comments.

    google-api-client depends on guava-jdk5, which creates a conflict with guava-18+, used by appengine-gcs-client

    <dependency>
        <groupId>com.google.api-client</groupId>
        <artifactId>google-api-client-appengine</artifactId>
        <version>1.20.0</version>
        <exclusions>
            <!-- creates conflicts with another guava version in appengine-gcs-client -->
            <exclusion>
                <groupId>com.google.guava</groupId>
                <artifactId>guava-jdk5</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    

    这篇关于在Maven清理/构建和部署后,Java App Engine调用GcsService.createOrReplace导致Stopwatch.createUnstarted noSuchMethodError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆