java.lang.NoClassDefFoundError: HttpServletRequest [duplicate]

末鹿安然 提交于 2021-01-28 03:42:11

问题


I might have done something really stupid. I was playing around with directories and what not, and now my tomcat server won't start my dynamic web project on eclipse. Please help. I don't know if this has something to do with the directory or not, but it's giving an error when I try to run my project in the server.

Caused by: java.lang.NoClassDefFoundError: HttpServletRequest
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.getDeclaredMethods(Class.java:1975)
    at org.apache.catalina.util.Introspection.getDeclaredMethods(Introspection.java:127)
    at org.apache.catalina.startup.WebAnnotationSet.loadMethodsAnnotation(WebAnnotationSet.java:273)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:133)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)
    at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:334)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:774)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:305)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more
Caused by: java.lang.ClassNotFoundException: HttpServletRequest
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
    ... 20 more

回答1:


Your Tomcat crashes due to

Caused by: java.lang.ClassNotFoundException: HttpServletRequest

Please check if you have javax.servlet-api library in your classpath.




回答2:


Project -> Configure build path -> Add library -> Server Runtime -> Apache Tomcat V8. It works now. Could someone please tell me why it would have been removed though? It was working perfectly fine earlier today.




回答3:


Based on java.lang.ClassNotFoundException: HttpServletRequest, I think you do not add the tomcat dependency libraries.



来源:https://stackoverflow.com/questions/34586736/java-lang-noclassdeffounderror-httpservletrequest

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