java - 谷歌云存储 : Could not initialize class OauthRawGcsServiceFactory

标签 java google-app-engine google-cloud-storage

我正在尝试使用 Google Cloud Storage Client Library 在 Appengine 上进行简单的上传和下载。

在执行期间,它返回这些错误:

java.lang.NoClassDefFoundError: Could not initialize class com.google.appengine.tools.cloudstorage.oauth.OauthRawGcsServiceFactory
    at com.google.appengine.tools.cloudstorage.GcsServiceFactory.createRawGcsService(GcsServiceFactory.java:42)
    at com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService(GcsServiceFactory.java:34)

错误指向这里:

    @Override
    public void doGet( HttpServletRequest request, HttpServletResponse response ) throws IOException {
        GcsFilename fileName = getFileName( request );

        GcsInputChannel readChannel = gcsService.openPrefetchingReadChannel(fileName, 0, BUFFER_SIZE);
        copy(Channels.newInputStream(readChannel), response.getOutputStream());
    }

    @Override
    public void doPost( HttpServletRequest request, HttpServletResponse response ) throws IOException {
        GcsOutputChannel outputChannel = gcsService.createOrReplace( getFileName(request), GcsFileOptions.getDefaultInstance() );
        copy( request.getInputStream(), Channels.newOutputStream(outputChannel) );
    }

我该如何解决?

最佳答案

您的 /war/WEB-INF/lib/ 文件夹中缺少一个必需的 jar。

首先,如果您使用 Eclipse,请检查“问题”选项卡中是否没有关于服务器上资源不可用的警告。如果看到它们,请右键单击 QuickFix 并选择“复制到...”选项。如果您不使用 Eclipse,请手动检查。

如果这没有帮助,请检查您是否包含项目所需的所有依赖项:

https://code.google.com/p/google-api-java-client/wiki/Setup#Download_Library_with_Dependencies

关于java - 谷歌云存储 : Could not initialize class OauthRawGcsServiceFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24339247/

相关文章:

google-cloud-storage - 如何等待作业完成或文件在 Airflow 中更新

node.js - 使用 Cloud Functions 的下载网址从 Firebase 存储中删除文件

java - file.mkdirs() 创建新目录但无法读取

android - 从 Android 到 Google App Engine 的简单文件上传?

python - 带有 web.py 和 Google App Engine 的空白页面

python - 谷歌云存储 api 性能回归

java - Spring Validation - 以编程方式绑定(bind)到 validator

java - Spring/Hibernate 响应中的属性为空

java - 基于 boolean 变量 Autowiring Spring Bean

mysql - 我应该在客户端代码中存储什么作为索引?