1

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 は Java オブジェクトではなく JSObject しか受け付けないのでしょうか?

4

1 に答える 1

1

ListGridRecordそれがあなたがしていることなら、それは単なるjavascriptオブジェクトであるため、サーバー側でインスタンス化できないとは思いません。あなたの rpc はシリアル化可能なオブジェクトを送信しており、クライアント側では、これらのオブジェクトに含まれるデータをオブジェクトListGridRecordまたはYouClassDerivatedFromListGridRecordオブジェクトに入力しています。

于 2012-10-18T06:33:41.230 に答える