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
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 :
When using Eclipse WDT and using unmodified and previously working project :
The above solution should resolve the exception.
Try to put the spring-web.jar file directly in the WEB-INF/lib (WEB-INF/lib/spring-web.jar) and not in WEB-INF/lib/spring-mvc/spring-web.jar
It's a dependency problem, some dependencies are missing in the artifact. My solution in IntelliJ:
Right Click on project name ->open module settings -> problems -> add missing dependencies to the artifact
Restart the server (my case was tomcat)
Hope it helps
If you are creating simple project without maven, need to follow following steps,
download required jar files, e.g. I am using spring 4 so I have downloaded files from Index of release
Then add this files inside your WebContent/WEB-INF/lib folder.
Add jar files in build path (In eclipse : Right click on project -> Properties -> Java Build Path -> Add JARs...)
This will avoid org.springframework.web.context.ContextLoaderListener exception.
I have a VERY GOOD WAY to help you learn Spring MVC if you have Maven up and running.
IF SO: go to your command line (Cygwin) I use...
mvn archetype:generate It will ask for an 'archetype number'. For you... type 16 Enter the group ID which is just the main package. Enter Artifact ID which is your project name. SNAP-SHOT --- just press enter and same with version. Package - is the same as your group ID name. EX: com.spring Confirm it by entering the letter 'y' and press enter. DO all of the above after your are in your workspace directory. That way it is created there. You can do "mvn eclipse:eclipse" to load it in Eclipse OR you can just import it. I prefer the old fashioned importing an existing project.
Everything will be 'already' set up for you in terms of ALL configuration (Java-Based) which is good for you. It will have all the Maven dependencies you need as well already in your pom.xml. You can add or take from it if you want.
The point here is that you will have a running project already and you can play with it from there. I create all my projects like this at first and erase what I don't need and add what I do and then go from there.
Good luck!!!