我创建了一个扩展com.smartgwt.client.widgets.grid.ListGridRecord并实现com.google.gwt.user.client.rpc.IsSerializable的类。我作为RPC的结果返回了一系列这样的对象。但是在开发模式下运行时会抛出异常
[java] SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
[java] com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract com.aman.gwt.test.shared.FriendRecord[] com.aman.gwt.test.client.FirstService.test()' threw an unexpected exception: java.lang.UnsatisfiedLinkError: com.smartgwt.client.util.JSOHelper.createObject()Lcom/google/gwt/core/client/JavaScriptObject;
[java] at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:389)
[java] at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:579)
[java] at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
[java] at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
[java] at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[java] at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
[java] at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[java] at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:110)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[java] at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[java] at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:61)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[java] at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[java] at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[java] at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[java] at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
[java] at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
[java] at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
[java] at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
[java] at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
[java] at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:94)
[java] at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[java] at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:380)
[java] at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[java] at org.mortbay.jetty.Server.handle(Server.java:326)
[java] at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
[java] at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
[java] at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
[java] at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
[java] at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
[java] at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
[java] at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
[java] Caused by: java.lang.UnsatisfiedLinkError: com.smartgwt.client.util.JSOHelper.createObject()Lcom/google/gwt/core/client/JavaScriptObject;
[java] at com.smartgwt.client.util.JSOHelper.createObject(Native Method)
[java] at com.smartgwt.client.core.DataClass.<init>(DataClass.java:35)
[java] at com.smartgwt.client.core.RefDataClass.<init>(RefDataClass.java:30)
[java] at com.smartgwt.client.data.Record.<init>(Record.java:59)
[java] at com.smartgwt.client.widgets.grid.ListGridRecord.<init>(ListGridRecord.java:127)
[java] at com.aman.gwt.test.shared.FriendRecord.<init>(FriendRecord.java:13)
[java] at com.aman.gwt.test.server.FirstServiceImpl.test(FirstServiceImpl.java:26)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:616)
[java] at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
[java] ... 38 more
[java]
[java] Oct 18, 2012 1:52:36 AM com.google.appengine.tools.development.LocalResourceFileServlet doGet
[java] WARNING: No file found for: /favicon.ico
共享类和服务实现方法是:
package com.aman.gwt.test.shared;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.google.gwt.user.client.rpc.IsSerializable;
public class FriendRecord extends ListGridRecord implements IsSerializable{
public FriendRecord(){
}
public FriendRecord(String name,String id){
setName(name);
setId(id);
}
public void setName(String name){
setAttribute("name",name);
}
//public void setImgSrc(String imgSrc){
//setAttribute("imgSrc",imgSrc);
//}
public void setId(String id){
setAttribute("id",id);
}
}
public FriendRecord[] test(){
FriendRecord[] fr = new FriendRecord[10];
for(int i=0;i<10;i++){
fr[i]=new FriendRecord("name"+i,String.valueOf(i*2));
}
return fr;
}
我做得对吗?我希望能够在这里做的就是用这些记录填充ListGrid。为什么ListGrid只接受JSObject而不接受Java对象?
答案 0 :(得分:1)
如果你正在做的事情我不认为你不能在服务器端实例化ListGridRecord
因为它只是一个javascript对象。你的rpc正在发送一个可服用的对象和客户端,你正在使用这些对象中包含的数据填充你的ListGridRecord
或YouClassDerivatedFromListGridRecord
个对象。