存档在 ‘框架整合’ 分类

Proxool 的HouseKeeper NullPointerException

2010年6月10日

使用Proxool连接池, 当在重启Tomcat容器时,出现    Exception in Thread "HouseKeeper" java.lang.NullPointerException 空指针异常错误。 原因是:

This is because Proxool is not being shutdown properly. If the JVM stops then Proxool recognises that and shuts down gracefully, but if you redeploy Proxool into some environments (for example, a servlet container) then Proxool needs to be explicitly told so by calling ProxoolFacade.shutdown(). If you have a servlet container then you could put it in the servlet’s destroy() method. Alternatively, use the ServletConfigurator to both configure and shutdown Proxool

阅读全文——共1403字

使用spring-modules-0.9实现注解缓存

2010年5月21日

 

关于spring实现ehcache有很多方法,很多都是利用aop来实现,我认为采用注解的方式更灵活,配置也更简洁。下面就是我利用spring-modules-0.9实现的注解缓存。

配置文件如下:

阅读全文——共1779字

基于springmodules的缓存方案

2010年5月21日

简介    

      通常在系统开发中,必不可少的要使用到缓存(Cache),如用户信息、字典信息都会使用缓存来提高性能;但是如何使用好缓存是个需要深入研究的话题,缓存方案没有通用性,针对不同的应用层面,缓存的设计通常也是千差万别的!这里只是介绍了一种比较轻量级、无侵入的缓存方案,该方案基于Spring+SpringModules。

目的

阅读全文——共3469字

OpenSessionInViewFilter作用及配置

2010年5月21日

一、作用

Spring为我们解决Hibernate的Session的关闭与开启问题。 Hibernate 允许对关联对象、属性进行延迟加载,但是必须保证延迟加载的操作限于同一个 Hibernate Session 范围之内进行。如果 Service 层返回一个启用了延迟加载功能的领域对象给 Web 层,当 Web 层访问到那些需要延迟加载的数据时,由于加载领域对象的 Hibernate Session 已经关闭,这些导致延迟加载数据的访问异常

(eg: org.hibernate.LazyInitializationException:(LazyInitializationException.java:42) – failed to lazily initialize a collection of role: cn.easyjava.bean.product.ProductType.childtypes, no session or session was closed org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: cn.easyjava.bean.product.ProductType.childtypes, no session or session was closed)

阅读全文——共6297字

SSH整合常见错误

2010年5月21日

1. org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): 原因:<id>元素配置不正确,<id>元素缺少其子元素<generator></generator>的配置。解决方法:<id>元素映射了相应数据库表的主键字段,对其子元素<generator class="">,其中class的取值可以为increment、identity、sequence、hilo、native……等,一般取其值为native 。

阅读全文——共4600字