6
回答
jfinal ehcache问题
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

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

谢谢。

举报
sober1841
发帖于2年前 6回/2K+阅
共有6个答案 最后回答: 2年前

@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)



引用来自“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() 这样的代码存在
顶部