jfinal ehcache问题

sober1841 发布于 2015/07/07 13:13
阅读 2K+
收藏 0

Jfinal确实很好。 这两天一直在照着demo在搭。 今天想加上ehcache. 以下是相关代码:

控制器:

@Before(CacheInterceptor.class)
	@CacheName("stocklist")
	public void index() {
		setAttr("stockPage", Stock.me.paginate(getParaToInt(0, 1), 5));
		renderJsp("StockIndex.jsp");
	}



ehcache.xml

<defaultCache
            name ="stocklist"
            maxElementsInMemory="10000"
            eternal="false"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            overflowToDisk="true"
            maxElementsOnDisk="10000000"
            diskPersistent="false"
            diskExpiryThreadIntervalSeconds="120"
            memoryStoreEvictionPolicy="LRU"
            
            />



当浏览器跳转到相关路径时:出错:

严重: /stock/
java.lang.NullPointerException
	at com.jfinal.plugin.ehcache.CacheKit.getOrAddCache(CacheKit.java:42)
	at com.jfinal.plugin.ehcache.CacheKit.get(CacheKit.java:63)
	at com.jfinal.plugin.ehcache.CacheInterceptor.intercept(CacheInterceptor.java:55)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:65)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:78)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)



不知道是怎么回事? @Jfinal

谢谢。

加载中
1
JFinal
JFinal

在 YourJFinalConfig 中添加即可打完收工:

me.add(new EhCachePlugin());


0
s
sober1841
搞定了! 谢谢。 我之前已经按照手册在config文件中写上了,不知怎么又被我屏蔽了。 不应该。 多谢急速回答@JFinal
0
如梦技术
如梦技术

@紫电清霜 的jfinal-bbs对ehcache用的比较精巧的http://www.oschina.net/p/jfinal-bbs,你可以参考参考~

0
s
sober1841
@孤独的3.   403错误。  不过论坛页面的截图挺好看。 
0
littleant
littleant

@Jfinal 大神有没遇过下面这种问题?jfinal整合ehcache使用时,有时候经常遇到这个异常信息

java.lang.IllegalStateException: The CacheManager has been shut down. It can no longer be used.
	at net.sf.ehcache.CacheManager.checkStatus(CacheManager.java:1621)
	at net.sf.ehcache.CacheManager.getCache(CacheManager.java:1155)
	at com.jfinal.plugin.ehcache.CacheKit.getOrAddCache(CacheKit.java:42)
	at com.jfinal.plugin.ehcache.CacheKit.get(CacheKit.java:63)



0
JFinal
JFinal

引用来自“littleant”的评论

@Jfinal 大神有没遇过下面这种问题?jfinal整合ehcache使用时,有时候经常遇到这个异常信息

java.lang.IllegalStateException: The CacheManager has been shut down. It can no longer be used.
	at net.sf.ehcache.CacheManager.checkStatus(CacheManager.java:1621)
	at net.sf.ehcache.CacheManager.getCache(CacheManager.java:1155)
	at com.jfinal.plugin.ehcache.CacheKit.getOrAddCache(CacheKit.java:42)
	at com.jfinal.plugin.ehcache.CacheKit.get(CacheKit.java:63)



从没遇到过,检查一下是否 EhCachePlugin.stop() 方法是否在哪里被调用过,再检查一下是否有  CacheKit.getCacheManager().shutdown() 这样的代码存在
返回顶部
顶部