My Resource bundle is working fine with Controllers and Services etc, but somehow I can't access it within a custom tag.
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:/spring/messages" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
Here is a part of the tag:
@Component
public class FormSection extends BodyTagSupport {
private static final long serialVersionUID = 1L;
@Autowired
private ReloadableResourceBundleMessageSource messageSource;
@Override
public int doStartTag() throws JspException {
try {
// messageSource causes a NULL POINTER here
messageSource.getMessage("name", null, new Locale("us")));
return EVAL_BODY_INCLUDE;
}
I am getting a NullPointerException; Autowire doenst work. I can see my class is being scanned.
I also tried using applicationContext by implementing ApplicationContextAware but doenst work:
messageSource = (ReloadableResourceBundleMessageSource)applicationContext.getBean("messageSource");
Any help is welcome!