GAE java.lang.IllegalStateException:必须首先调用 set*BlobStorage() 之一 [英] GAE java.lang.IllegalStateException: Must call one of set*BlobStorage() first

查看:16
本文介绍了GAE java.lang.IllegalStateException:必须首先调用 set*BlobStorage() 之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Blobstore API 在 GAE 中上传文件.在本地运行 GAE 服务器(开发模式)时出现以下异常:

I am trying to upload a file in GAE using the Blobstore API. I am getting the following exception when running the GAE server locally (dev mode):

WARNING: /_ah/upload/ag10cmlwc2NoZWR1bGVychsLEhVfX0Jsb2JVcGxvYWRTZXNzaW9uX18YFQw
java.lang.IllegalStateException: Must call one of set*BlobStorage() first.
 at com.google.appengine.api.blobstore.dev.BlobStorageFactory.getBlobStorage(BlobStorageFactory.java:24)
 at com.google.appengine.api.blobstore.dev.UploadBlobServlet.init(UploadBlobServlet.java:88)
 at javax.servlet.GenericServlet.init(GenericServlet.java:215)
 at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)
 at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
 at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)

我正在运行 GAE 1.3.5,但已经尝试了自 GAE 1.3.0(带有 Blobstore 的第一个版本)以来的所有版本.我正在使用 GAE maven 插件:http://code.google.com/p/maven-gae-plugin/

I am running GAE 1.3.5 but have tried all versions since GAE 1.3.0 (first version with the Blobstore). I am using the GAE maven plugin: http://code.google.com/p/maven-gae-plugin/

我的表单是用 GWT 2.0.4 编写的.目前,表单只是一个带有提交的文件输入字段.

My form is written in GWT 2.0.4. Currently, the form is just a file input field with a submit.

我在提交表单后收到上述异常.我能够从 Blobstore 服务成功检索上传 URL.

I receive the above exception after submitting the form. I am able to successfully retrieve an upload URL from the Blobstore Service.

在 GAE 上一切正常.我已经验证在我的本地开发环境中没有任何东西输入到 blobstore(通过开发管理控制台).我正在上传一个 ~1Kb 的 CSV,但也尝试了其他文件类型/大小但没有成功(相同的文件适用于 GAE prod).

Everything works fine on GAE. I have verified that nothing is entered into the blobstore in my local dev env (via the dev admin console). I am uploading a CSV that is ~1Kb but have tried other file types/sizes as well without success (same files work on GAE prod).

推荐答案

该问题是由于在运行开发应用服务器时将存根和测试 jar 包含在类路径中引起的.如果您使用的是 maven,只需更改依赖项的范围:

The issue was caused by having the stubs and testing jars included on the classpath when running the dev app server. If you are using maven, simply change the scope of the dependency:

<dependency>
    <groupId>com.google.appengine</groupId>
    <artifactId>appengine-api-stubs</artifactId>
    <version>${gae.version}</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>com.google.appengine</groupId>
    <artifactId>appengine-testing</artifactId>
    <version>${gae.version}</version>
    <scope>test</scope>
</dependency>

如果您不使用 maven,请确保这些 jar 不在您的 WEB-INF/lib 或类路径中.

If you are not using maven, make sure these jars are not in your WEB-INF/lib or classpath.

这篇关于GAE java.lang.IllegalStateException:必须首先调用 set*BlobStorage() 之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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