Spring+RMI+Hibernate发布多个服务(接口)思路

2014-11-24 02:53:22 · 作者: · 浏览: 2

spring+RMI+hibernate发布多个服务(接口)思路,在配置的时候如果是两个服务,则发布两个RmiServiceExporter的bean。


客户端这边也在配置文件中设置两个bean定义RmiProxyFactoryBean。在调用的时候对不同的服务,使用不同的getBean。


例如:服务端的配置文件:

class="org.springframework.remoting.rmi.RmiServiceExporter">

LogPerson

com.hibernate.ILogPerson

1200


class="org.springframework.remoting.rmi.RmiServiceExporter">


Bay

com.hibernate.IBay


1200

客户端的配置文件:

class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
rmi://192.168.25.10:1200/LogPerson
com.hibernate.ILogPerson


class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
rmi://192.168.25.10:1200/Bay
com.hibernate.IBay


主程序中调用的方法:
//获得RMI服务
ILogPerson clientLog = (ILogPerson) cfactory.getBean("LogPerson");
IBay clientBay = (IBay) cfactory.getBean("Bay");
在做关联类的时候报错


问题:
Exception in thread "main" org.springframework.remoting.RemoteAccessException:
Could not access remote service [rmi://192.168.25.10:1199/BankService];
nested exception is java.rmi.MarshalException: error marshalling arguments;
nested exception is: java.io.NotSerializableException: springexample.hibernate.Account


at springexample.hibernate.TestClient.main(TestClient.java:40)
Caused by: java.rmi.MarshalException: error marshalling arguments; nested exception is:
Caused by: java.io.NotSerializableException: springexample.hibernate.Account


解决:
这个单词的意思居然没没明白marshalling arguments
就是用到的实体类没有从可以序列化类中继承过来啦!


相关阅读: