1

I am trying to debug an issue with RequestMappingHandlerAdapter initialization and I have come to a conclusion by searching the Web that it is getting initialized from mvc:annotation-driven xml entry. Can anyone explain me briefly, how this initialization works i.e. what happens when the parser parses mvc:annotation-driven? Or point me to the code that does it and I will trace it through.

Some more context on this:

I was trying to get RequestMappingHandlerAdapter from the context via autowire but could not. It gave me:

No matching bean of type [org.springframework.web.servlet.mvc.method.annotation.RequestMappingH
andlerAdapter]
expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

Found this thread, but the solution does not does not work: Spring, Jackson and Customization (e.g. CustomDeserializer)

I am using: Spring 3.1.3

This is what my servlet xml file looks like ...

<context:annotation-config />
<context:component-scan base-package="com.xyz" />
<mvc:annotation-driven />

Thanks, Parth

Community
  • 1
  • 1
Parth
  • 523
  • 1
  • 7
  • 21
  • It just hit me that the order of mvc:annotation-driven config was wrong. I reversed it and it worked! – Parth Feb 08 '13 at 09:09

1 Answers1

0

I would think it would cause either the AnnotationConfigApplicationContext or AnnotationConfigWebApplicationContext to search for the annotated classes and create/graph them. One way to figure things out would be to make a bean that throws a RuntimeException in its default constructor and see what the stack trace looks like.

CodeChimp
  • 8,016
  • 5
  • 41
  • 79