GWT Blobstore error calling createUploadUrl()
Asked Answered
F

3

8

I am attempt to use the Blobstore api for appengine using GWT... I promise you! I had it working for months and suddenly I started get the following errors.. arfter executing the following line from a servelet.

public class ImageServiceImpl extends RemoteServiceServlet implements ImageService {

    /**
 * 
 */
private static final long serialVersionUID = 1L;

  // init the blog store service
private BlobstoreService blobService = BlobstoreServiceFactory.getBlobstoreService();
    //private static final Logger log = Logger.getLogger(ImageServiceImpl.class);
    public static final String PATH_TO_DEFAULT_IMAGE = "images/no_photo.jpg";

. . . . . // omitted for brevity }

    @Override
    public String getUpLoadPath() {
        String url = blobService.createUploadUrl("/n5/doimage");
        return url;
    }

}

Initializing App Engine server Sep 19, 2011 7:28:45 PM com.google.apphosting.utils.jetty.JettyLogger info INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger Sep 19, 2011 7:28:45 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml INFO: Successfully processed C:\development\n5\n5\war\WEB-INF/appengine-web.xml Sep 19, 2011 7:28:45 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml INFO: Successfully processed C:\development\n5\n5\war\WEB-INF/web.xml Sep 19, 2011 3:28:47 PM com.google.appengine.tools.development.DevAppServerImpl start INFO: The server is running at http://localhost:8888/ Sep 19, 2011 7:34:59 PM com.google.appengine.tools.development.ApiProxyLocalImpl log SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.lang.String com.six.n5.client.service.ImageService.getUpLoadPath()' threw an unexpected exception: java.lang.VerifyError: class com.google.appengine.api.blobstore.BlobstoreServicePb$CreateUploadURLRequest overrides final method isInitialized.()Z at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385) at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588) at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208) at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248) at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:216) at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:141) at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:93) at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:63) at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:122) at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:110) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:58) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:351) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) Caused by: java.lang.VerifyError: class com.google.appengine.api.blobstore.BlobstoreServicePb$CreateUploadURLRequest overrides final method isInitialized.()Z at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:176) at java.lang.ClassLoader.loadClass(Unknown Source) at com.google.appengine.api.blobstore.BlobstoreServiceImpl.createUploadUrl(BlobstoreServiceImpl.java:43) at com.google.appengine.api.blobstore.BlobstoreServiceImpl.createUploadUrl(BlobstoreServiceImpl.java:34) at com.six.n5.server.ImageServiceImpl.getUpLoadPath(ImageServiceImpl.java:153) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100) at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569) ... 39 more

Failing answered 19/9, 2011 at 19:45 Comment(0)
F
12

I found my own error! as it turn out the reason this was suddenly failing was because the FORM post thought it was cross domain posting. I was testing the web site by calling 127.0.0.1:8888..etc but when the when my Image RPC was called to establish the upload path, it returned to the form setAction the my machine name kmoore-PC:8888..etc instead of the 127.0.0.1:8888... and hence it returned null because it thought it was crossing domains.

To fix, click on the google box in url bar and add your computer name and then test you app using the computer name instead of 127

Failing answered 12/10, 2011 at 3:0 Comment(0)
A
0

I tried replacing local host with machine name it didn't help, but it is a cross domain java-script issue so I tried just using the URL pattern assigned in the web xml and I got a String result. The result is my response wrapped with XML and I plan to parse it. if any one has something more elegant please tell me.

here is the response String [it looks a bit different because it affects the stack overflow page]:

pre style="word-wrap: break-word; white-space: pre-wrap;">my response id

Here is the relevant server code

public void doPost(HttpServletRequest request, HttpServletResponse response) throws >ServletException, IOException { //Redirect recursively to this servlet (calls doGet) response.sendRedirect("/blobstoreexample/uploadservice?id=" + >item_image_blob_key); } }

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException 
{
    System.out.println("shonka");
  //Send the meta-data id back to the client in the HttpServletResponse response
  String id = req.getParameter("id");

  response.getWriter().write(id);
  return;

}

Here is the relevant client code, no need for parsing here is the server side code:

uploadForm.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
      @Override
      public void onSubmitComplete(SubmitCompleteEvent event) {

        //The submit complete Event Results will contain the unique
        //identifier for the picture's meta-data.  Trim it to remove
        //trailing spaces and line breaks
          System.out.println("uploadForm onSubmitComplete() results are: " + event.getResults());

          Window.alert(event.getResults());
          if(event.getResults() != null)
          {
             // getPicture(event.getResults().trim());
          }
          else
          {
              Window.alert(event.getResults());
          }

      }

    });

Edit I found a more elegant way to deliver a long id

//Redirect recursively to this servlet (calls doGet)
        response.sendRedirect("/itemmanager/receive?id=" + item.getKey().getId());
      }

      @Override
      protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
      {
          System.out.println("entered do post");
        //Send the meta-data id back to the client in the HttpServletResponse response
        String id = req.getParameter("id");
        System.out.println("entered do post id is: " + id);
        resp.setHeader("Content-Type", "text/html");
        resp.getWriter().println(id);

      }
Apatetic answered 27/6, 2013 at 4:52 Comment(0)
B
0

Instead of using the computer name, I simply replace it with the 127 address when in dev mode, like so:

String url = blobstoreService.createUploadUrl("/project/uploadservice");

// change the computer name to standard localhost ip address, if in dev mode
if(SystemProperty.environment.value() == SystemProperty.Environment.Value.Development)
{
    url = url.replace("Your-PC-Name", "127.0.0.1");
}
Blondy answered 13/9, 2013 at 14:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.