在put上使用Hibernate ehCache空指针异常

时间:2011-08-03 22:17:06

标签: hibernate ehcache

这是我的配置。

<?xml version="1.0" encoding="UTF-8"?>

<ehcache>    
<defaultCache
    maxElementsInMemory="500000"
    eternal="false"
    timeToIdleSeconds="120"
    timeToLiveSeconds="120"
    overflowToDisk="true"
/>
<cache
    name="com.icon.sa.common.dm.PromoItem"
    maxElementsInMemory="500000"
    eternal="false"
    timeToIdleSeconds="300"
    timeToLiveSeconds="600"
    overflowToDisk="true"
/>
<cache
    name="org.hibernate.cache.StandardQueryCache"
    maxElementsInMemory="500000"
    eternal="false"
    timeToLiveSeconds="120"
    overflowToDisk="true"/>
<cache
    name="org.hibernate.cache.UpdateTimestampsCache"
    maxElementsInMemory="500000"
    eternal="true"
    overflowToDisk="true"/>

<cache name="query.PromosBySearchRequestFindAction"
    maxElementsInMemory="500000"
    eternal="false"
    timeToLiveSeconds="86400"
    overflowToDisk="true"/>

</ehcache>

当我尝试执行query.list()时,我得到了这个异常

Aug 3, 2011 3:10:56 PM org.hibernate.cache.UpdateTimestampsCache <init>
INFO: starting update timestamps cache at region: org.hibernate.cache.UpdateTimestampsCache
Aug 3, 2011 3:10:56 PM org.hibernate.cache.StandardQueryCache <init>
INFO: starting query cache at region: org.hibernate.cache.StandardQueryCache
Time before db: Wed Aug 03 15:10:57 PDT 2011
Aug 3, 2011 3:10:57 PM org.hibernate.cache.StandardQueryCache <init>
INFO: starting query cache at region: query.PromosBySearchRequestFindAction
Aug 3, 2011 3:10:57 PM com.icon.sa.service.action.BaseAction perform
SEVERE: class com.icon.sa.service.action.euser.PromosBySearchRequestFindAction
java.lang.NullPointerException
    at org.hibernate.type.TypeHelper.disassemble(TypeHelper.java:146)
    at org.hibernate.cache.StandardQueryCache.put(StandardQueryCache.java:106)
    at org.hibernate.loader.Loader.putResultInQueryCache(Loader.java:2434)
    at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2321)
    at org.hibernate.loader.Loader.list(Loader.java:2268)
    at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
    at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
    at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
    at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
    at com.icon.sa.common.dm.dao.PromoItemDao.findAllReleasedBySearchRequest(PromoItemDao.java:121)
    at com.icon.sa.service.action.euser.PromosBySearchRequestFindAction.doWork(PromosBySearchRequestFindAction.java:63)
    at com.icon.sa.service.action.BaseAction.perform(BaseAction.java:61)
    at com.icon.sa.ws.euser.PromosResource.get(PromosResource.java:86)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:168)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:70)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:279)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:136)
    at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:121)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:136)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:86)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:136)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:74)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1357)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1289)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1239)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1229)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:420)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:497)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:684)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)

1 个答案:

答案 0 :(得分:2)

这与ehCache本身没什么关系。

引发错误,因为一个(或所有)结果类型为null

从堆栈跟踪判断,您已为实体配置了自定义加载程序。可能是它没有被正确声明(特别是结果类/返回别名),或者它需要自动发现类型(声明为“select * ...”),这与缓存不一致。