java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener in eclipse

前端 未结 5 1298
暖寄归人
暖寄归人 2020-12-09 20:04

I am doing a simple Spring MVC application(not using maven) which will print hello world on browser. It is a dynamic project in eclipse, so I put all the required jar files

5条回答
  •  猫巷女王i
    2020-12-09 20:12

    I had this same problem in Eclipse. When I would do a maven clean install and move the generated WAR file to my Tomcat webapp folder it would run with no problems. However, inorder to debug I wanted to run in Eclipse but it would throw the following error.

    SEVERE: Error configuring application listener of class   org.springframework.web.context.ContextLoaderListener
    

    I googled around until I found the following blog post.

    http://commonexceptions.blogspot.com/2014/01/java.html

    As the author explains:

    This exception was caused when i did not add the maven dependencies to the build path. I was using eclipse with maven, so had to include the maven dependencies in the build path as explained below.

    See the post for the solution. It is a simple eclipse Deployment Assembly configuration fix. Took me about 30 seconds and now I can debug my Spring webapp in Eclipse.

    Here are the relevant steps from the post:

    Adding Maven dependencies in project web deployment assembly :

    • Open project properties(example: In project explorer rightClick on project name to select "Properties").
    • Select "Deployment Assembly".
    • Click "Add..." button on the right navigation.
    • Select "Java Build Path Entries" from menu of Directive Type and then click "Next".
    • Select "Maven Dependencies" from Java Build Path Entries menu
    • click "Finish".
    • Now the "Maven Dependencies" should be added to the Web Deployment Assembly and it should run.

    When using Eclipse WDT and using unmodified and previously working project :

    • If Tomcat is running Stop it
    • Open the "Servers" view: Window then select "Show view" and then select "Other" > Server > Servers
    • Right Click on the Tomcat Server and then select "Clean Tomcat Work Directory".
    • Right Click on the Tomcat Server and then select "Clean"
    • Restart the Tomcat Server

    The above solution should resolve the exception.

提交回复
热议问题