4

I'm getting an exception that "org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" does not exist in my WebContent\WEB-INF\spring-dispatcher-servlet.xml file. I have the spring-webmvc 4.1.2 dependency added and I the class exists in my maven dependencies so it's as though it isn't seeing those classes from my maven dependencies?

 <bean id="HandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" /> 

2 Answers 2

2

If you are using eclipse, try clean project, and then clean Tomcat directory. Also make sure that maven dependencies are present in WEB-INF/lib, if not, this is configurable from Project Properties > Deployment Assembly

Sign up to request clarification or add additional context in comments.

4 Comments

It appears there are no spring jars in the WEB-INF/lib folder, here is my deployment assembly: i.imgur.com/OogS59X.png is this configuration correct?
Yes, its correct, just try Project>Clean... After that open servers view in eclipse, right click on tomcat and click Clean...
Project->clean worked thanks! Any reason behind why this would work?
It has to do with eclipse-tomcat integration. When a dependency is added to the webapp, this doesn't get synchronized with the tomcat deploy directory, e.i dependency doesn't get copied to WEB-INF/lib, so the developer have to click Tomcat>Clean... which redeploys the webapp.
1

You probably have multiple versions of spring-webmvc on your classpath as dependencies of other direct dependency. Call mvn dependency:tree -Dverbose -Dincludes=spring-webmvc to see how many versions of the library you have and exclude older versions.

Or, if you are using Intellij, enable the maven plug-in, generate diagram, search with Ctrl-F for spring-webmvc and where you have older dependency right click on it and choose exclude. Probably eclipse has similar functionality too.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.