
hessian的主要結構分客戶端與服務端,中間基於http傳輸。客戶端主要做的事情是把對遠程接口調用序列化為流,並傳輸到服務端;服務端主要做的事情是把傳輸過來的流反序列化為對服務的請求,調用相應服務后把結果序列化為流返回給客戶端。一次完整的調用如下圖所示:
HessianProxy是hessian client處理客戶端請求的核心類,它采用proxy的設計模式,代理客戶端對遠程接口的調用,hessian client的主流程的時序圖如下所示:
HessianSkeleton是hessian server端的核心類,從輸入流中返序列化出客戶端調用的方法和參數,對服務端服務進行調用,然后把處理結果返回給客戶端,主要流程時序圖如下所示:

錯誤配置(不需要配置bean id="",因為此實現類直接在class中用注解配置,交由spring管理。):
<!-- <bean id="dataCommBizServiceImpl" class="com.xinwei.process.service.impl.DataCommBizServiceImpl"></bean> -->
<bean name="/dataCommBiz" class="org.springframework.remoting.caucho.HessianServiceExporter">
<property name="service" ref="dataCommBizServiceImpl" />
<property name="serviceInterface" value="com.xinwei.process.service.DataCommBizService" />
</bean>
classpath下新建hessian-servlet.xml ,注意這里不要定義 bean id ="" ,否則會導致hessain接口實現類中通過注解注入spring 中的bean 如 Dao時無法注入,出現null 異常
INFO: Initializing Spring FrameworkServlet 'hessianServlet'
2017-03-30 08:51:47,722 [localhost-startStop-1] INFO [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping] - Mapped URL path [/sayHello] onto handler '/sayHello'
2017-03-30 08:51:47,723 [localhost-startStop-1] INFO [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping] - Mapped URL path [/dataCommBiz] onto handler '/dataCommBiz'
2017-03-30 08:51:47,723 [localhost-startStop-1] INFO [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping] - Mapped URL path [/dataPrivilege] onto handler '/dataPrivilege'
2017-03-30 08:51:47,782 [localhost-startStop-1] INFO [org.springframework.web.servlet.DispatcherServlet] - FrameworkServlet 'hessianServlet': initialization completed in 245 ms
三月 30, 2017 8:51:47 上午 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
三月 30, 2017 8:51:47 上午 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
三月 30, 2017 8:51:47 上午 org.apache.catalina.startup.Catalina start
INFO: Server startup in 14562 ms
server method invoked!
服務端方法被調用!
2017-03-30 08:52:17,349 [http-bio-8080-exec-4] DEBUG [com.xinwei.process.service.impl.DataCommBizServiceImpl] - selectAll:null
2017-03-30 08:52:17,366 [http-bio-8080-exec-4] WARN [org.springframework.remoting.support.RemoteInvocationTraceInterceptor] - Processing of HessianServiceExporter remote call resulted in fatal exception: com.xinwei.process.service.DataCommBizService.selectAll
java.lang.NullPointerException
at com.xinwei.process.service.impl.DataCommBizServiceImpl.selectAll(DataCommBizServiceImpl.java:35)
例子: http://www.cnblogs.com/langtianya/p/4981880.html