Reputation: 738
Hi. I am new to java and GWT. I have RPC call to get some values from Filenet, I using GWT, where am using RPC call,
I have 3 methods in FcInterface.java which extends remoteservices. 2 methods in the interface are working fine returning the values to client from serber. But there is problem with 3rd method, I can’t return the value from server side to client side.
Attaching the code n stack trace.
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;
}
}
Code for class 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;
}
}
StackTrace
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)
I guess there is problem with serialization or I cant send the obect of FilenetFolderImpl using ContentOfRootFolder which is of type
Map<String, Object> ContentOfRootFolder = new HashMap<String, Object>();
In any case I need to return the values of FilenetFolderImpl
.
Please help me to solve this problem. Thanks.
Upvotes: 0
Views: 1358
Reputation: 2214
To use FilenetFolderImpl
class in your client code, it must use only those classes that are emulated by the GWT framework. GregorianCalendar
which is used byFilenetFolderImpl
isnt an emulated class.
FilenetFolderImpl
needs implement Serializable
if you are planning to exchange it between client and server.
Also note that FilenetFolderImpl
needs to be in the package that you have chosen to "share" between your client and server code.
Upvotes: 1
Reputation: 9900
You cannot just send any objects over the network in GWT-RPC. Only classes which are included in GWT emulation library and classes used in client side can be transferred. You'll have to create DTO or move FilenetFolderImpl to the client package (but you have to remember that GregorianCalendar is not included in emulated library as well, so you'll have to do something about it).
Upvotes: 3