Announcement Announcement Module
Collapse
No announcement yet.
Controller not found by context:component-scan Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Controller not found by context:component-scan

    Hi!

    Im using spring 3.0.3.

    For me it seems that even though i specify the following in the app-servlet.xml:

    <context:component-scan base-package="x.y"/>

    My java class in that specific package marked with the @Controller annotation is not found. At least it's constructor does not run and when i try to access the resource mapped to one of the methods of this class with the @RequestMapping annotation tomcat says the resource is not available...

    Do you have any idea what could be the problem?

  • #2
    Meanwhile I found in the logs that when i deploy the application my Controller is found and the specified resources are bound to the methods of the controller...

    even though the mapping still does not work.

    is having a AnnotationMethodHandlerAdapter required? Isnt the default should work as well?

    Comment


    • #3
      Since you're using 3.0.3 drop the component-scan and just throw in the <mvc:annotation-driven/> which will fully configure your web mvc (including declaration of the adapter, which is required to make it work). Also, check out how you mapped your DispatcherServlet in web.xml, maybe the address you are using in your controller is not even processed by DispatcherServlet. Next to that, remember that the mvc:annotation-driven (or context:component-scan) must be put in your web mvc specific context configuration xml, and not in your core Spring context configuration xml.

      Comment


      • #4
        Thank you very much for your help! The problem was - as you guessed it right - that i forgot to update the servlet-mapping in the web.xml.

        I will take a look at the solution that you recommended as well!

        Comment

        Working...
        X