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

问题描述

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

 警告:/ _ah / upload / ag10cmlwc2NoZWR1bGVychsLEhVfX0Jsb2JVcGxvYWRTZXNzaW9uX18YFQw 
java.lang.IllegalStateException:必须首先调用set * BlobStorage()之一。
在com.google.appengine.api.blobstore.dev.BlobStorageFactory.getBlobStorage(BlobStorageFactory.java:24)
在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)
在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插件:



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



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



在GAE上一切正常。我已经证实,我的本地开发环境(通过开发人员管理控制台)中没有任何内容输入到Blobstore中。我上传了大约1Kb的CSV,但尝试了其他文件类型/大小,但都没有成功(相同的文件在GAE prod上运行)。

解决方案这个问题是由于在运行开发应用程序服务器时在类路径中包含存根和测试jar引起的。如果您使用的是maven,只需更改依赖项的范围:

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

如果您不使用maven,请确保这些jar不在您的WEB-INF / lib或classpath。


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)

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/

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

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

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).

解决方案

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>

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()之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 10:48