title: Spring MessageSource not getting message from properties file
body: <p>I did some googling around and found my problem have appeared many times but i have tried all suggested solutions but it is still not working for me</p>
  
  <p>I am keep getting this exception:</p>
  
  <pre><code>org.springframework.context.NoSuchMessageException: No message found under code 'error.null.firstname' for locale 'en'.
  </code></pre>
  
  <p>here is my setup
  in my dispatcher-servlet.xml file i have:
  </p>
  
  <pre><code>&lt;bean id="messageSource"
      class="org.springframework.context.support.ResourceBundleMessageSource"&gt;
      &lt;property name="basename" value = "error"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>i have a properties file (error_en.properties) under src/main/resources/ directly
  and it does contain the following line:</p>
  
  <pre><code>error.null.firstname=Firstname cannot be null
  </code></pre>
  
  <p>in my code i am trying:
   </p>
  
  <pre><code>    @Autowired
      private MessageSource messageSource;
      ...
      System.out.println(messageSource.getMessage("error.null.firstname", null, Locale.ENGLISH));
  </code></pre>
  
  <p>but above is not working and is giving me exception mentioned above</p>
  
  <p>I've tried prefixing "classpath:" to 'value' in value attribute but that didn't work for me.
  I've ensured that the filename 'error' matches with the value attribute because i know '_en' would be dealt with by Spring Framework.</p>
  
  <p>I can't see what am i missing? </p>