gpt4 book ai didi

java - 调度传入 RPC 调用时出现异常

转载 作者:行者123 更新时间:2023-12-01 19:10:01 28 4
gpt4 key购买 nike

嗨。我是 java 和 GWT 新手。我有 RPC 调用从 Filenet 获取一些值,我使用 GWT,其中使用 RPC 调用,

我在 FcInterface.java 中有 3 个扩展远程服务的方法。接口(interface)中的 2 个方法工作正常,将值从服务器返回给客户端。但是第三种方法有问题,无法将值从服务器端返回到客户端。

附加代码和堆栈跟踪。

   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 的值.

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

最佳答案

您不能仅在 GWT-RPC 中通过网络发送任何对象。只能传输 GWT 仿真库中包含的类和客户端使用的类。您必须创建 DTO 或将 FilenetFolderImpl 移动到客户端包(但您必须记住 GregorianCalendar 也不包含在模拟库中,因此您必须对此采取一些措施)。

关于java - 调度传入 RPC 调用时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8678743/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com