我需要使用RMI为客户发送药物治疗计划。服务器和客户端位于单独的项目中,都定义了以下类(实体和远程接口):
public class Plan implements Serializable {
private Integer id;
private Date periodStart;
private Date periodEnd;
private Integer patientId;
private Medication medications;
}
public class Medication implements Serializable {
private Integer id;
private String name;
private Integer dosage;
private Integer intakeInterval;
}
public interface PillService extends Remote {
public Plan getPlan(int id) throws RemoteException;
}
上面的代码可以正常工作,但是我需要在Plan
中列出如下药物清单:
public class Plan implements Serializable {
...
private List<Medication> medications;
}
如果我与此Plan
类一起运行,则会遇到此异常:
Client exception: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassnotFoundException: org.hibernate.collection.internal.PersistentBag (no security manager: RMI class loader disabled)
此后,我向SecutiryManager
添加了System
,但出现错误:
java.security.accessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve")
at java.security.accessControlContext.checkPermission(accessControlContext.java:472)
因此,在List<Medication>
中没有Plan
的情况下也可以正常工作。 RMI不喜欢复合对象吗?我是否应该定义一种新的远程方法来分别获取药物清单?