couldn't clear tomcat cache

转自:http://www.cnblogs.com/bobshieh/p/5373793.html

最近在项目中实现一个文件传输功能时,每完成一次操作tomcat8中总是抛出如下异常:

警告: couldn't clear tomcat cache
java.lang.NoSuchFieldException: resourceEntries
    at java.lang.Class.getDeclaredField(Unknown Source)
    at com.opensymphony.xwork2.util.LocalizedTextUtil.clearMap(LocalizedTextUtil.java:735)
    at com.opensymphony.xwork2.util.LocalizedTextUtil.clearTomcatCache(LocalizedTextUtil.java:719)
    at com.opensymphony.xwork2.util.LocalizedTextUtil.reloadBundles(LocalizedTextUtil.java:703)
    at com.opensymphony.xwork2.util.LocalizedTextUtil.findDefaultText(LocalizedTextUtil.java:178)
    at com.opensymphony.xwork2.util.LocalizedTextUtil.getDefaultMessage(LocalizedTextUtil.java:579)
    at com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:461)
    at com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:293)
    at org.apache.struts2.interceptor.FileUploadInterceptor.getTextMessage(FileUploadInterceptor.java:368)
    at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:277)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)

 

虽然不影响使用,but maybe it is a time bomb! 于是决定找出原因。搜索了一番,发现解决方案大概有两种:

方案一:

因为tomcat8没有属性resourceEntries,换成tomcat7就好了。但是从tomcat8==>tomcat7感觉在退步,果断拒绝此方法。

参考链接:http://blog.csdn.net/findbestoy/article/details/50756465

 

方案二:

升级struts版本,struts2.0.9==>struts2.3.20,完美解决问题,坚决采纳本方法!

struts2.3.20下载地址:http://download.csdn.net/detail/xyznad/9486393

参考链接:http://blog.csdn.net/bigtree_3721/article/details/50866958

 

=========================================================

注意,要把strust2.1之前的版本换成新版本,需要另外加入一下jar包:

commons-lang3-3.2.jar、javassist-3.11.0.GA.jar,并且各个jar包要同一个版本。

同时,在web.xml中,

如果struts2版本是2.1以前:

<filter>  
  <filter-name>struts2</filter-name>  
  <filter-class>org.apache.struts2.dispatcher.FilterDispatcher  
</filter-class>  
  </filter>  
  <filter-mapping>  
  <filter-name>struts2</filter-name>  
  <url-pattern>/*</url-pattern>  
  </filter-mapping>  
</web-app> 

 如果struts2 版本是2.1以上:

    <filter>  
      <filter-name>struts2</filter-name>  
      <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter  
    </filter-class>  
      </filter>  
      <filter-mapping>  
      <filter-name>struts2</filter-name>  
      <url-pattern>/*</url-pattern>  
      </filter-mapping>  
    </web-app>  

 

posted @ 2017-09-05 19:06  半生戎马,共话桑麻、  阅读(1521)  评论(0)    收藏  举报
levels of contents