Framework: Spring 3.
I really can't understand why the message source injectend in a bean ends up always to be NULL.
Here's the snippets:
the servlet.xml
<context:annotation-config />
<context:component-scan base-package="com.myproject.controllers" />
<mvc:annotation-driven />
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="/WEB-INF/messages/messages" />
<property name="cacheSeconds" value="0" />
</bean>
the class where the messageSource is injected
import com.myproject.controllers.forms.RegistrationForm;
@Component
public class RegistrationFormValidator implements Validator {
@Autowired
@Qualifier("messageSource")
private MessageSource messageSource;
//other stuff here...
}
here's the controller
@Controller
@SessionAttributes("userSearchForm")
public class UsersController extends PaginationController<ProfiledUser>{
@InitBinder(value="registrationForm")
public void initBinder(WebDataBinder binder)
{
binder.setValidator(new RegistrationFormValidator());
}
I have already tried the following:
- deleting the annotations and injecting the message source via xml configuration file
- implementing the MessageSourceAware interface
- trying to inject a
ReloadableresourceBundleMessageSource
instead of using interfaceMessageSource
everything ends up in a epic fail ;-) How can I get the MessageSource properly injected?