GWT Blobstore 调用 createUploadUrl() 时出错
我尝试使用 GWT 将 Blobstore api 用于 appengine... 我答应你!我已经让它工作了几个月,突然我开始了 得到以下错误..执行以下行后 一个servlet。
公共类 ImageServiceImpl 扩展 RemoteServiceServlet 实现 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";
. 。 。 。 。 // 为简洁起见省略 初始化
@Override
public String getUpLoadPath() {
String url = blobService.createUploadUrl("/n5/doimage");
return url;
}
服务器
App Engine 2011 年 9 月 19 日 7:28:45 PM com.google.apphosting.utils.jetty.JettyLogger 信息 信息:通过 com.google.apphosting.utils.jetty.JettyLogger 记录到 JettyLogger(null) 2011 年 9 月 19 日 7:28:45 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml 信息:已成功处理 C:\development\n5\n5\war\WEB-INF/appengine-web.xml 2011 年 9 月 19 日下午 7:28:45 com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml 信息:已成功处理 C:\development\n5\n5\war\WEB-INF/web.xml 2011 年 9 月 19 日下午 3:28:47 com.google.appengine.tools.development.DevAppServerImpl 启动 信息:服务器正在 http://localhost:8888/ 运行 2011 年 9 月 19 日下午 7:34:59 com.google.appengine.tools.development.ApiProxyLocalImpl 日志 严重:javax.servlet.ServletContext 日志:分派传入 RPC 调用时出现异常 com.google.gwt.user.server.rpc.UnexpectedException:服务方法“公共抽象java.lang.String com.6.n5.client.service.ImageService.getUpLoadPath()”抛出意外异常:java.lang.VerifyError :com.google.appengine.api.blobstore.BlobstoreServicePb$CreateUploadURLRequest 类会覆盖最终方法 isInitialized.()Z 在 com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385) 在 com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588) 在 com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208) 在 com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248) 在 com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:637) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 在 com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:216) 在 com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:141) 在 com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:93) 在 com.google.inject.servlet.FilterChainInspiration.doFilter(FilterChainInspiration.java:63) 在 com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:122) 在 com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:110) 在 org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 在 com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35) 在 org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 在 com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:58) 在 org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 在 com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43) 在 org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 在 com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122) 在 org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 在 com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97) 在 org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 在 org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) 在 org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) 在 org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) 在 org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) 在 org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) 在 com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70) 在 org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 在 com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:351) 在 org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 在 org.mortbay.jetty.Server.handle(Server.java:326) 在 org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) 在 org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938) 在 org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755) 在 org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218) 在 org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) 在 org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) 在 org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) 引起原因:java.lang.VerifyError:类 com.google.appengine.api.blobstore.BlobstoreServicePb$CreateUploadURLRequest 覆盖最终方法 isInitialized.()Z 在 java.lang.ClassLoader.defineClass1(本机方法) 在 java.lang.ClassLoader.defineClass(来源未知) 在 java.security.SecureClassLoader.defineClass(来源未知) 在 java.net.URLClassLoader.defineClass(来源未知) 在 java.net.URLClassLoader.access$100(来源不明) 在 java.net.URLClassLoader$1.run(来源未知) 在 java.net.URLClassLoader$1.run(来源未知) 在 java.security.AccessController.doPrivileged(本机方法) 在 java.net.URLClassLoader.findClass(来源未知) 在 java.lang.ClassLoader.loadClass(来源未知) 在 com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:176) 在 java.lang.ClassLoader.loadClass(来源未知) 在 com.google.appengine.api.blobstore.BlobstoreServiceImpl.createUploadUrl(BlobstoreServiceImpl.java:43) 在 com.google.appengine.api.blobstore.BlobstoreServiceImpl.createUploadUrl(BlobstoreServiceImpl.java:34) 在 com.6.n5.server.ImageServiceImpl.getUpLoadPath(ImageServiceImpl.java:153) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 在 sun.reflect.NativeMethodAccessorImpl.invoke(来源未知) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(来源未知) 在 java.lang.reflect.Method.invoke(来源未知) 在 com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100) 在 com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569) ... 39 更多
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现了我自己的错误!事实证明,这突然失败的原因是因为 FORM 帖子认为它是跨域发布。我通过调用 127.0.0.1:8888..etc 来测试该网站,但是当调用我的 Image RPC 来建立上传路径时,它返回到表单 setAction 我的计算机名称 kmoore-PC:8888..etc 127.0.0.1:8888...因此它返回 null,因为它认为它正在跨域。
要修复此问题,请单击网址栏中的 google 框并添加您的计算机名称,然后使用计算机名称而不是 127 测试您的应用程序
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
我尝试用机器名替换本地主机,但没有帮助,但这是一个跨域 java 脚本问题,因此我尝试仅使用 Web xml 中分配的 URL 模式,并得到了一个字符串结果。结果是我用 XML 包装的响应,我计划解析它。如果有人有更优雅的东西请告诉我。
这是响应字符串[它看起来有点不同,因为它影响堆栈溢出页面]:
这是相关的服务器代码
是相关的客户端代码,无需解析这里是服务器端代码:
编辑我找到了一种更优雅的方式来传递长id
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]:
Here is the relevant server code
Here is the relevant client code, no need for parsing here is the server side code:
Edit I found a more elegant way to deliver a long id
在开发模式下,我没有使用计算机名称,而是将其替换为 127 地址,如下所示:
Instead of using the computer name, I simply replace it with the 127 address when in dev mode, like so: