你好我是java和GWT的新手。
我使用RPC调用从Filenet获取一些值,我使用GWT,在这里使用RPC调用,

我在FcInterface.java中有3种方法可以扩展远程服务。接口中的2种方法都可以正常工作,将值从serber返回给客户端。但是第3种方法存在问题,我无法将值从服务器端返回给客户端。

附加代码n堆栈跟踪。

   Code:
    public class FilenetCmisServiceImpl extends RemoteServiceServlet implements FcInterface {
    ...
    ...Some codes
    public Map<String, Object> getContentOfRootFolder(String RepositoryId) {
    Map<String, Object> ContentOfRootFolder = new HashMap<String, Object>();
    ItemIterable<CmisObject> children = root.getChildren();
    for (CmisObject o : children) {
       FilenetFolderImpl folder= new FilenetFolderImpl();
        folder.setFolderName(o.getName());
        folder.setFolderId(o.getId());
        folder.setFolderModifiedBy(o.getLastModifiedBy());
        folder.setFolderClass(o.getBaseTypeId().toString());
        folder.setFolderModifiedOn(o.getLastModificationDate());
        System.
        out.println("name : " + o.getName());
        ContentOfRootFolder.put(o.getName(), folder);

        }// every thing is fine till here
          return ContentOfRootFolder;
      }
    }


类FilenetFolderImpl的代码

       public class FilenetFolderImpl  {

private String FolderName;
private String FolderSize;
private String FolderModifiedBy;
private GregorianCalendar FolderModifiedOn;
Folder root;
private String FolderId;
private String FolderClass;


public FilenetFolderImpl( String Foldername){

    this.FolderName=Foldername;

}
 public FilenetFolderImpl(String name, String id, String baseTypeId,
        GregorianCalendar lastModificationDate, String lastModifiedBy) {
    // TODO Auto-generated constructor stub
     this.FolderName = name;
     this.FolderId = id;
     this.FolderClass = baseTypeId;
     this.FolderModifiedBy = lastModifiedBy;
     this.FolderModifiedOn = lastModificationDate;

}
public FilenetFolderImpl() {
        // TODO Auto-generated constructor stub
}
public String getFolderName() {
    return FolderName;
    }
    public void setFolderName(String FolderName) {
       this.FolderName=FolderName;
    }
    public String getFolderId() {
        return FolderId;
    }
    public void setFolderId(String FolderId) {
       this.FolderId=FolderId;
    }
    public String getFolderClass() {
        return FolderClass;
    }
    public void setFolderClass(String FolderClass){
       this.FolderClass=FolderClass;
    }
    public String getFolderModifiedBy() {
        return FolderModifiedBy;
    }
    public void setFolderModifiedBy(String FolderModifiedBy) {
       this.FolderModifiedBy=FolderModifiedBy;
    }
    public GregorianCalendar getFolderModifiedOn() {
        return FolderModifiedOn;
    }

    public void setFolderModifiedOn(GregorianCalendar gregorianCalendar) {
       this.FolderModifiedOn=gregorianCalendar;
    }
    protected Map<String, String> addFolder(){
        Map<String, String> newFolderProperties = new HashMap<String, String>();
        newFolderProperties.put(PropertyIds.OBJECT_TYPE_ID,"cmis:folder");
        newFolderProperties.put(PropertyIds.NAME,FolderName);
         return newFolderProperties;
    }
     }


堆栈跟踪

      Exception while dispatching incoming RPC call
    Type 'com.filenet.cmis.server.FilenetFolderImpl' was not included in the set of types which    can be serialized by this SerializationPolicy or its Class object could not be loaded. For      security purposes, this type will not be serialized.: instance  =com.filenet.cmis.server.FilenetFolderImpl@eca5f5
      at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(
       ServerSerializationStreamWriter.java:619)
        at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(
        AbstractSerializationStreamWriter.java:126)
       at com.google.gwt.user.client.rpc.core.java.util.Map_CustomFieldSerializerBase.serialize(
   Map_CustomFieldSerializerBase.java:53)
       at com.google.gwt.user.client.rpc.core.java.util.HashMap_CustomFieldSerializer.serialize(
     HashMap_CustomFieldSerializer.java:39)
         at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(
RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(
RemoteServiceServlet.java:248)

  Type 'com.filenet.cmis.server.FilenetFolderImpl' was not included in the set of
  types which can be serialized by this SerializationPolicy or its Class object
  could not be loaded. For security purposes, this type will not
  be serialized.: instance = com.filenet.cmis.server.FilenetFolderImpl@eca5f5


 at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(
 ServerSerializationStreamWriter.java:619)
 at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(
 AbstractSerializationStreamWriter.java:126)
 at com.google.gwt.user.client.rpc.core.java.util.Map_CustomFieldSerializerBase.serialize(
 Map_CustomFieldSerializerBase.java:53)
 at com.google.gwt.user.client.rpc.core.java.util.HashMap_CustomFieldSerializer.serialize(
 HashMap_CustomFieldSerializer.java:39)
 at com.google.gwt.user.client.rpc.core.java.util.HashMap_CustomFieldSerializer.serializeInstance( HashMap_CustomFieldSerializer.java:51)
 at com.google.gwt.user.client.rpc.core.java.util.HashMap_CustomFieldSerializer.serializeInstance(
 HashMap_CustomFieldSerializer.java:28)
 at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(
 ServerSerializationStreamWriter.java:740)
  at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(
 ServerSerializationStreamWriter.java:621)
  at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(
  AbstractSerializationStreamWriter.java:126)


我猜序列化有问题,或者我不能使用ContentOfRootFolder发送FilenetFolderImpl的对象
         Map<String, Object> ContentOfRootFolder = new HashMap<String, Object>();
无论如何,我都需要返回FilenetFolderImpl的值。

请帮我解决这个问题。
谢谢。

最佳答案

要在客户端代码中使用FilenetFolderImpl类,它必须仅使用GWT框架模拟的那些类。 GregorianCalendar使用的FilenetFolderImpl不是模拟类。

如果您打算在客户端和服务器之间交换FilenetFolderImpl,则Serializable需要实现FilenetFolderImpl

另请注意,必须位于您选择的在客户端和服务器代码之间“共享”的包中。

10-04 18:58