GAE java.lang.IllegalStateException: Must call one of set*BlobStorage() first
Asked Answered
B

5

3

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

Bremble answered 4/8, 2010 at 2:41 Comment(0)
B
3

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.

Bremble answered 27/9, 2010 at 15:31 Comment(0)
C
5

When call your page that generates html (using servlet, jsp, etc.) and calls blobstoreService.createUploadUrl("/upload"); you can't re-use this page multiple times.

Reload this page in a browser every time you want to upload the file.

Cusp answered 20/5, 2011 at 10:59 Comment(0)
B
3

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.

Bremble answered 27/9, 2010 at 15:31 Comment(0)
S
2
$ mvn clean gae:run -DskipTest 

works for me

Southbound answered 19/6, 2012 at 23:30 Comment(0)
J
0

I am not using Maven, just Eclipse and the GAE plugins. I also didn't see any test.jar files in my classpath. I just deleted the Run Configuration in Eclipse and restarted and it worked. No idea what went wrong, but this fixed the issue for me while running in dev/local mode.

Justinajustine answered 17/10, 2011 at 1:2 Comment(2)
hey Dustin, could you please elaborate what exactly you deleted in Run Configuration? I am facing the same issue.Luciana
It has been a while since I posted, but I believe I just deleted the entire run configuration in eclipse (Run->Run Configurations...->Google App Engine, then selected the config and clicked delete (the red 'X')).Justinajustine
P
0

If not using maven but Eclipse with plugin:

REMOVE RUN/DEBUG CONFIGURATION. To create new, simply right click on project and select run/debug As > Web Application

Psychotechnics answered 14/4, 2012 at 10:5 Comment(1)
Only it looks as if he was asking for maven, so…Pushed

© 2022 - 2024 — McMap. All rights reserved.