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

hessian 在spring中的使用 (bean 如 Dao无法注入的问题)的更多相关文章

  1. Spring中常见的bean创建异常

    Spring中常见的bean创建异常 1. 概述     本次我们将讨论在spring中BeanFactory创建bean实例时经常遇到的异常 org.springframework.beans.fa ...

  2. 【转】Spring 中三种Bean配置方式比较

    今天被问到Spring中Bean的配置方式,很尴尬,只想到了基于XML的配置方式,其他的一时想不起来了,看来Spring的内容还没有完全梳理清楚,见到一篇不错的文章,就先转过来了. 以前Java框架基 ...

  3. Spring 中三种Bean配置方式比较

    今天被问到Spring中Bean的配置方式,很尴尬,只想到了基于XML的配置方式,其他的一时想不起来了,看来Spring的内容还没有完全梳理清楚,见到一篇不错的文章,就先转过来了. 以前Java框架基 ...

  4. Spring中如何向 Bean注入系统属性或环境变量

    [转自] http://unmi.cc/spring-injection-system-properties-env/ 在 Spring 中为 javabean 注入属性文件中的属性值一般人都知道的, ...

  5. spring中自动装配bean

    首先用@Component注解类: package soundsystem: import org.springframework.stereotype.Component; @Component p ...

  6. Spring中@Component与@Bean的区别

    @Component和@Bean的目的是一样的,都是注册bean到Spring容器中. @Component  VS  @Bean @Component 和 它的子类型(@Controller, @S ...

  7. 半夜思考之查漏补缺, 在 Spring中, 所有的 bean 都是 Spring 创建的吗 ?

    Spring 是一个 bean 容器, 负责 bean 的创建, 那么所有的 bean对象都是 Spring 容器创建的吗 ? 答案是否定的. 但是乍一想, 好像所有的对象都是 Spring 容器负责 ...

  8. 解决Spring中singleton的Bean依赖于prototype的Bean的问题

    在spring bean的配置的时候,可能会出现一个singleton的bean依赖一个prototype的bean.因为singleton的bean只有一次初始化的机会,所以他们的依赖关系页只有在初 ...

  9. Spring 中初始化一个Bean对象时依赖其他Bean对象空指针异常

    1. Bean依赖关系 一个配置类的Bean,一个实例Bean: 实例Bean初始化时需要依赖配置类的Bean: 1.1 配置类Bean @ConfigurationProperties(prefix ...

随机推荐

  1. PHP之null

    null类型 特殊的null值表示一个变量没有值.null类型唯一可能的值是null. 在下列情况下一个变量被认为是null: ①.被赋值为null ②.尚未被赋值 ③被unset(). 语法 nul ...

  2. Win10+Ubuntu18.04 UEFI启动模式SSD+HDD

    新手操作徒手安装Ubuntu,踩坑无数. 分享一篇好的经验:https://blog.csdn.net/xrinosvip/article/details/80428133(下附原博客) 踩坑大集合: ...

  3. AndrewNG Deep learning课程笔记

    神经网络基础 Deep learning就是深层神经网络 神经网络的结构如下, 这是两层神经网络,输入层一般不算在内,分别是hidden layer和output layer hidden layer ...

  4. ios APP改名推送名字还是旧的

    重启手机就行了 https://community.jiguang.cn/t/ios-app/14759

  5. LeetCode 748 Shortest Completing Word 解题报告

    题目要求 Find the minimum length word from a given dictionary words, which has all the letters from the ...

  6. 2018/03/07 每日一个Linux命令 之 cat

    每日一个Linux命令 2018-03-07 Linux 命令 cat cat [-参数] fileName 在之前的Linux使用中 cat 命令一直作为文本输出指令来使用,很少可以深入学习的该命令 ...

  7. 第二章 构建布局良好的windows程序

    工具箱→菜单和工具栏 菜单栏 MenuStrip的类型 MenuItem:菜单项 TextBox:文本框 ComboBoX:组合框 Separato:分割线 前面都有ToolStrip做前缀 Appl ...

  8. 【JMeter】【性能测试】正则表达式关联

    1:登录接口 这里有一个实际的登录接口,在响应中返回了一串token,如下图 那么我们在接下来的接口-经验库列表中,就必须带入这一串token,否则响应报错,如下图所示   测试开发交流群 31776 ...

  9. 多周期MACD趋势共振制作的方法

    我浏览了创幻论坛.理想论坛,来到MACD股市技术分析俱乐部,真正找到自己的乐土. 做人要厚道!指标之王MACD既然被先辈们创造了出来,就应由我辈发扬光大!自吹自擂者.吝啬者都应自觉退出论坛既然来到这里 ...

  10. 001-分布式理论-CAP定理

    一.概述 CAP原则又称CAP定理,指的是在一个分布式系统中,Consistency(一致性). Availability(可用性).Partition tolerance(分区容错性)这三个基本需求 ...