java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistrations()Ljava/util/Map;

懵懂的女人 提交于 2019-12-13 04:43:05

问题


I followed the steps in BalusC's answer at JSF 2.0 File upload. The only step in which I went differently is the Tomahawk upload link in the answer. The link is broken, so I got tomahawk-1.1.11 from another place. When I try to start Tomcat 7.0.14 from Eclipse I get the following error:

java.lang.NoSuchMethodError: 
javax.servlet.ServletContext.getServletRegistrations()Ljava/util/Map;

And Tomcat doesn't start. Any ideas? Also, the answer in the link is from March. Any developments with file upload in JSF 2?


回答1:


The /WEB-INF/lib of your web project is cluttered with servletcontainer-specific libraries of a container of a different make/version, such as servlet-api.jar, javaee.jar, etc. Get rid of them.

The mentioned method is introduced in Servlet 3.0 and this error indicates that you've libraries of a Servlet 2.5 container or older in your /WEB-INF/lib. If you have included them to circumvent Eclipse's compilation errors on javax.servlet.* imports, then you should have solved it differently. Namely, by integrating the servletcontainer which you're actually going to use (which is Tomcat 7 in your case) as target runtime in Eclipse and associating the project with it.

Please note that this problem is not related to JSF 2.0. You got an exception pointing to a method of the javax.servlet package, not javax.faces package.

See also:

  • How do I import the javax.servlet API in my Eclipse project?


来源:https://stackoverflow.com/questions/8286041/java-lang-nosuchmethoderror-javax-servlet-servletcontext-getservletregistratio

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!