Java NoClassDefFoundError com/google/api/services/storage/storage$Builder
执行GCS图像上载步骤并从URL下载最新文件后Java NoClassDefFoundError com/google/api/services/storage/storage$Builder,java,google-app-engine,Java,Google App Engine,执行GCS图像上载步骤并从URL下载最新文件后 https://developers.google.com/api-client-library/java/google-api-java-client/download 下面是代码 public class GcsExample { private static GcsService gcsService = GcsServiceFactory.createGcsService(); // Error during initia
https://developers.google.com/api-client-library/java/google-api-java-client/download
下面是代码
public class GcsExample {
private static GcsService gcsService = GcsServiceFactory.createGcsService();
// Error during initialization
public void doPost(String gcsFilename, byte[] data) throws IOException {
GcsFilename filename = new GcsFilename("niranttest2.appspot.com", gcsFilename);
com.google.appengine.tools.cloudstorage.GcsFileOptions.Builder fileOptionsBuilder = new GcsFileOptions.Builder();
fileOptionsBuilder.mimeType("image/jpeg");
GcsFileOptions fileOptions = fileOptionsBuilder.build();
GcsOutputChannel outputChannel = gcsService.createOrReplace(filename, fileOptions);
// write file out
BufferedOutputStream outStream = new BufferedOutputStream(Channels.newOutputStream(outputChannel));
List<byte[]> allBytes = new LinkedList<byte[]>();
allBytes.add(data);
for (byte[] b : allBytes) {
outStream.write(b);
}
outStream.close();
outputChannel.close();
}
}
我相信这是由于appengine-gcs-client-0.5.jar文件导致的错误,但我已经尝试使用appengine-gcs-client-0.3.jar,它再次抛出了相同的错误。看起来您使用的是原始存储客户机(正如我从
GcsServiceFactory.createRawGcsService
中看到的),我猜是因为您在appengine之外使用它。也许这是必须的
该类来自google api服务存储库
lib,您应该添加以下依赖项:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-storage</artifactId>
<version>v1-rev66-1.21.0</version>
</dependency>
com.google.api
谷歌api服务存储
v1-rev66-1.21.0
看来您使用的是原始存储客户端(正如我从GcsServiceFactory.createRawGcsService
中看到的),我猜是因为您在应用程序引擎之外使用它。也许这是必须的
该类来自google api服务存储库
lib,您应该添加以下依赖项:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-storage</artifactId>
<version>v1-rev66-1.21.0</version>
</dependency>
com.google.api
谷歌api服务存储
v1-rev66-1.21.0
非常感谢Igor,在添加上述jar文件后,我得到了以下错误java.lang.NoClassDefFoundError:com/google/appengine/repackaged/org/joda/time/DateTimeZone,通过它的库解决了这个问题,最后它成功了。1000XThanks:)非常感谢Igor,在添加了上面的jar文件之后,我得到了下面的错误java.lang.NoClassDefFoundError:com/google/appengine/repackaged/org/joda/time/DateTimeZone,通过它的库解决了这个问题,最后它成功了。1000X汉克斯:)
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-storage</artifactId>
<version>v1-rev66-1.21.0</version>
</dependency>