首页 > 技术文章 > tomcat部署项目报错NoSuchMethodException#addServlet,addFilter

Jeely 2019-07-31 16:37 原文

java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addServlet
java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addFilter
 
这个问题折腾了我三四天,现在终于找到原因了。
是web-inf/lib包下包含了catalina.jar这个jar包,导致加载的时候使用了这个jar但是没有找到addServlet,addFilter
解决方法:Go to your WEB-INf/lib and remove catalina.*.jar, then restart your tomcat. 
 
http://stackoverflow.com/questions/27102375/using-code-based-configuration-getting-java-lang-nosuchmethodexception-org-apac/27102430#27102430
 
还是老外的网站牛逼。百度了几天答案千篇一律:解决方法为:在Tomacat7的context.xml文件里的<Context>中加上<Loader delegate="true" />
http://nvry.iteye.com/blog/1726163  
1
2
3
4
<Context>
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <Loader delegate="true" />
</Context>

可能能解决某些人的问题吧,反正解决不了我的问题。
 
 
######################
另一个问题:WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:firstProject' did not find a matching property.
 
解决Setting property 'source' to 'org.eclipse.jst.jee.server的问题
http://blog.csdn.net/z69183787/article/details/19911935
这个教程对这个问题很全面的解决和分析
 
 
 
 
 
########## 还有一个问题 ###############
The method list(String, Object[]) is ambiguous for the type BaseDAOImpl<M,PK
 
http://www.cnblogs.com/wujianxingzhe/p/5623827.html
原因:eclipse 的一个bug,具体见http://stackoverflow.com/questions/10852923/method-is-ambiguous-for-the-type-but-the-types-are-not-ambigues-and-the-error 
解决方法:在eclipse.ini -vmargs后面添加  -DtolerateIllegalAmbiguousVarargsInvocation=true ;重启eclipse,并clean一下项目 重新编译即可。

推荐阅读