GWT RequestFactory 与 Objectify:触发请求时返回 ServerFailure 错误
我正在尝试在 Eclipse 上自定义 App Engine Connected Android 项目。我使用 Objectify 代替 JPA,并一直遵循 Turbocharge 示例设置我的基本框架(使用 DAO 层)。
我目前正在处理 Web 方面的工作,但我无法让我的实体保留在开发服务器上:我的请求在接收器的 onFailure() 方法上返回 ServerFailure 错误。但并没有真正提供任何关于原因的线索(所有变量均为空)。
任何帮助将不胜感激!
这是我的 EntryPoint 类:
public class Manager implements EntryPoint {
private static final Logger log = Logger.getLogger(Manager.class.getName());
private final EventBus eventBus = new SimpleEventBus();
private ManagerRequestFactory rf = GWT.create(ManagerRequestFactory.class);
@Override
public void onModuleLoad() {
GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void onUncaughtException(Throwable e) {
log.finest("uncaught exception: ");
e.printStackTrace();
}
});
rf.initialize(eventBus);
log.setLevel(Level.FINE);
PersonRequest personRequest = rf.personRequest();
// Populate the database with sample data
PersonProxy person = personRequest.create(PersonProxy.class);
person.setFirstName("John1");
person.setLastName("Doe");
person.setEmail("[email protected]");
person.setMainPhone("215-555-1212");
personRequest.saveAndReturn(person).fire(new Receiver<PersonProxy>(){
@Override
public void onSuccess(PersonProxy response) {
log.info("got response: " + response.getFirstName());
}
@Override
public void onFailure(ServerFailure error) {
log.info("Server Failure type: " + error.getExceptionType());
log.info("Failure message: " + error.getMessage());
log.info("Stack Trace: " + error.getStackTraceString());
log.info(error.isFatal() ? "error is fatal" : "error is not fatal");
super.onFailure(error);
}
});
我在调试模式下跟踪代码通过堆栈直到它返回错误的位置。这是堆栈
守护线程 [来自 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML,如 Gecko) Chrome/16.0.912.75 Safari/535.7 的管理器代码服务器 http://127.0.0.1:8888/manager/hosted.html?manager @ d6:JVCMo.q:W,$wW](已暂停(异常 UmbrellaException))
AbstractRequestContext$StandardPayloadDialect.processPayload(Receiver<Void>, String) line: 387
AbstractRequestContext$5.onTransportSuccess(String) line: 1108
DefaultRequestTransport$1.onResponseReceived(Request, Response) line: 136
Request.fireOnResponseReceived(RequestCallback) line: 287
RequestBuilder$1.onReadyStateChange(XMLHttpRequest) line: 395
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available
Method.invoke(Object, Object...) line: not available
MethodAdaptor.invoke(Object, Object...) line: 103
MethodDispatch.invoke(JsValue, JsValue[], JsValue) line: 71
OophmSessionHandler.invoke(BrowserChannelServer, BrowserChannel$Value, int, BrowserChannel$Value[]) line: 172
BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer$SessionHandlerServer) line: 337
BrowserChannelServer.invokeJavascript(CompilingClassLoader, JsValueOOPHM, String, JsValueOOPHM[], JsValueOOPHM) line: 218
ModuleSpaceOOPHM.doInvoke(String, Object, Class<?>[], Object[]) line: 136
ModuleSpaceOOPHM(ModuleSpace).invokeNative(String, Object, Class<?>[], Object[]) line: 561
ModuleSpaceOOPHM(ModuleSpace).invokeNativeObject(String, Object, Class<?>[], Object[]) line: 269
JavaScriptHost.invokeNativeObject(String, Object, Class<?>[], Object[]) line: 91
Impl.apply(Object, Object, Object) line: not available
Impl.entry0(Object, Object, Object) line: 213
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available
Method.invoke(Object, Object...) line: not available
MethodAdaptor.invoke(Object, Object...) line: 103
MethodDispatch.invoke(JsValue, JsValue[], JsValue) line: 71
OophmSessionHandler.invoke(BrowserChannelServer, BrowserChannel$Value, int, BrowserChannel$Value[]) line: 172
BrowserChannelServer.reactToMessages(BrowserChannelServer$SessionHandlerServer) line: 292
BrowserChannelServer.processConnection() line: 546
BrowserChannelServer.run() line: 363
Thread.run() line: not available
在这里我有响应和错误变量的快照:
response ResponseMessageAutoBean$1 (id=566)
this$0 ResponseMessageAutoBean (id=581)
data JsonSplittable (id=583)
array null
bool null
isNull false
number null
obj JSONObject (id=597)
reified HashMap<K,V> (id=598)
string null
factory MessageFactoryImpl (id=584)
creatorMap JavaScriptObject$ (id=608)
enumToStringMap HashMap<K,V> (id=609)
stringsToEnumsMap HashMap<K,V> (id=610)
frozen false
shim ResponseMessageAutoBean$1 (id=566)
this$0 ResponseMessageAutoBean (id=581)
data JsonSplittable (id=583)
factory MessageFactoryImpl (id=584)
frozen false
shim ResponseMessageAutoBean$1 (id=566)
tags null
usingSimplePeer true
wrapped ResponseMessageAutoBean$2 (id=587)
tags null
usingSimplePeer true
wrapped ResponseMessageAutoBean$2 (id=587)
causes HashSet<E> (id=570)
[0] RuntimeException (id=576)
cause RuntimeException (id=576)
detailMessage "Server Error: null" (id=579)
stackTrace null
I'm trying to customize the App Engine Connected Android project on Eclipse. I'm using Objectify in place of JPA and have been following the Turbocharge example to setup my basic framework (using a DAO layer).
I'm currently working on the web side of things, but I'm having trouble getting my entities to persist on the development server: my requests return a ServerFailure error on Receivers' onFailure() method. But doesn't really provide any clues as to why that is (all variables are null).
Any help would be greatly appreciated!
Here's my EntryPoint class:
public class Manager implements EntryPoint {
private static final Logger log = Logger.getLogger(Manager.class.getName());
private final EventBus eventBus = new SimpleEventBus();
private ManagerRequestFactory rf = GWT.create(ManagerRequestFactory.class);
@Override
public void onModuleLoad() {
GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void onUncaughtException(Throwable e) {
log.finest("uncaught exception: ");
e.printStackTrace();
}
});
rf.initialize(eventBus);
log.setLevel(Level.FINE);
PersonRequest personRequest = rf.personRequest();
// Populate the database with sample data
PersonProxy person = personRequest.create(PersonProxy.class);
person.setFirstName("John1");
person.setLastName("Doe");
person.setEmail("[email protected]");
person.setMainPhone("215-555-1212");
personRequest.saveAndReturn(person).fire(new Receiver<PersonProxy>(){
@Override
public void onSuccess(PersonProxy response) {
log.info("got response: " + response.getFirstName());
}
@Override
public void onFailure(ServerFailure error) {
log.info("Server Failure type: " + error.getExceptionType());
log.info("Failure message: " + error.getMessage());
log.info("Stack Trace: " + error.getStackTraceString());
log.info(error.isFatal() ? "error is fatal" : "error is not fatal");
super.onFailure(error);
}
});
I followed the code in debug mode through the stacks to the point where it returns the error. Here's the Stack
Daemon Thread [Code server for manager from Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7 on http://127.0.0.1:8888/manager/hosted.html?manager @ d6:JVCMo.q:W,$wW] (Suspended (exception UmbrellaException))
AbstractRequestContext$StandardPayloadDialect.processPayload(Receiver<Void>, String) line: 387
AbstractRequestContext$5.onTransportSuccess(String) line: 1108
DefaultRequestTransport$1.onResponseReceived(Request, Response) line: 136
Request.fireOnResponseReceived(RequestCallback) line: 287
RequestBuilder$1.onReadyStateChange(XMLHttpRequest) line: 395
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available
Method.invoke(Object, Object...) line: not available
MethodAdaptor.invoke(Object, Object...) line: 103
MethodDispatch.invoke(JsValue, JsValue[], JsValue) line: 71
OophmSessionHandler.invoke(BrowserChannelServer, BrowserChannel$Value, int, BrowserChannel$Value[]) line: 172
BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer$SessionHandlerServer) line: 337
BrowserChannelServer.invokeJavascript(CompilingClassLoader, JsValueOOPHM, String, JsValueOOPHM[], JsValueOOPHM) line: 218
ModuleSpaceOOPHM.doInvoke(String, Object, Class<?>[], Object[]) line: 136
ModuleSpaceOOPHM(ModuleSpace).invokeNative(String, Object, Class<?>[], Object[]) line: 561
ModuleSpaceOOPHM(ModuleSpace).invokeNativeObject(String, Object, Class<?>[], Object[]) line: 269
JavaScriptHost.invokeNativeObject(String, Object, Class<?>[], Object[]) line: 91
Impl.apply(Object, Object, Object) line: not available
Impl.entry0(Object, Object, Object) line: 213
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available
Method.invoke(Object, Object...) line: not available
MethodAdaptor.invoke(Object, Object...) line: 103
MethodDispatch.invoke(JsValue, JsValue[], JsValue) line: 71
OophmSessionHandler.invoke(BrowserChannelServer, BrowserChannel$Value, int, BrowserChannel$Value[]) line: 172
BrowserChannelServer.reactToMessages(BrowserChannelServer$SessionHandlerServer) line: 292
BrowserChannelServer.processConnection() line: 546
BrowserChannelServer.run() line: 363
Thread.run() line: not available
And here I have a snapshot of the Variables for response and error:
response ResponseMessageAutoBean$1 (id=566)
this$0 ResponseMessageAutoBean (id=581)
data JsonSplittable (id=583)
array null
bool null
isNull false
number null
obj JSONObject (id=597)
reified HashMap<K,V> (id=598)
string null
factory MessageFactoryImpl (id=584)
creatorMap JavaScriptObject$ (id=608)
enumToStringMap HashMap<K,V> (id=609)
stringsToEnumsMap HashMap<K,V> (id=610)
frozen false
shim ResponseMessageAutoBean$1 (id=566)
this$0 ResponseMessageAutoBean (id=581)
data JsonSplittable (id=583)
factory MessageFactoryImpl (id=584)
frozen false
shim ResponseMessageAutoBean$1 (id=566)
tags null
usingSimplePeer true
wrapped ResponseMessageAutoBean$2 (id=587)
tags null
usingSimplePeer true
wrapped ResponseMessageAutoBean$2 (id=587)
causes HashSet<E> (id=570)
[0] RuntimeException (id=576)
cause RuntimeException (id=576)
detailMessage "Server Error: null" (id=579)
stackTrace null
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此错误表明服务器出现错误,因此“服务器错误:null” - 引发了异常,但没有与之关联的消息发送到客户端。根据您的代码,它可能位于服务器上的 saveAndReturn 方法中。尝试单步执行该步骤,或者使用 try/catch 围绕方法主体以获取错误。如果发生错误时使用了足够的日志记录,您的服务器日志可能会更清楚地说明该问题。
This error indicates that the server had an error, hence "Server Error: null" - an exception was thrown, but no message was associated with it to send to the client. Based on your code, it is probably in the saveAndReturn method on the server. Try stepping through there, or surrounding the body of the method with a try/catch to get the error. Your server log may shed more light on the issue, if enough logging is being used when errors occur.