Reputation: 1550
I've got a really annoying issue... I've not defined a Controller handler mapper and therefore I'm using the DefaultAnnotationHandlerMapping
class. My issue seems to have something to do with the Controller bean name mapping to the Controller class e.g.
Incoming request to dispatcher -> index.htm
With the following Controller class:
@Controller
public class IndexController {
@RequestMapping(value = "/index.htm", method = RequestMethod.GET)
public String loginForm(ModelMap model) {
return "index";
}
}
Should map index.htm to indexController bean and then to IndexController class. I can see from the logs that Spring has registered the bean with the container however I get the following error:
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [xxx.controller.IndexController]
I know for certain that the class exists (because the bean name is derived from it).
The strange thing is that if I name my controller the same as the bean name (e.g. indexController) everything is fine!! (Obviously I don't want my classes to have a lower case first letter!!)
Just to note that I've used the following in my dispatcher-servlet.xml:
<mvc:annotation-driven />
<context:component-scan base-package="xxx" />
JLove
Upvotes: 0
Views: 2383
Reputation: 17524
This error usually means your class has not been bundled in the war file. Unzip the war file and check your class is included correctly.
I suspect you successfully bundled "indexController.class" at some point, but prior packaging attempts failed. You haven't indicated how you are packaging your application, check your Maven/Ant configuration if you are using one of those. Beware of sharing build directories between IDE and build script, as they can occasionally conflict with each other.
Upvotes: 2
Reputation: 1738
I'd advice you to download STS and create new Spring MVC project template, to see, how Spring 3 MVC works.
Upvotes: -1