title: ResourceBundle [messages] not found for MessageSource: Can't find bundle for base name messages
body: <p>In applicationContext.xml I have defined MessageSource like this:</p>
  
  <pre><code>&lt;bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt;
      &lt;property name="basenames"&gt;
          &lt;list&gt;
              &lt;value&gt;/WEB-INF/i18n/messages&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I also need to load all the localized messages so I have made my own class for it:</p>
  
  <pre><code>public class ErpMessageSource extends ResourceBundleMessageSource {
  
      public Map&lt;String, String&gt; getMessages(String basename, Locale locale) {
          Set&lt;String&gt; keys = getKeys(basename, locale);
          Map&lt;String, String&gt; m = new HashMap&lt;String, String&gt;();
  
          for (String key : keys) {
              try {
                  m.put(key, getMessage(key, null, locale));              
              } catch (Exception e) {
                  System.err.println(key + " - " + e.getLocalizedMessage());
              }
          }
  
          return m;
      }
  
      private Set&lt;String&gt; getKeys(String basename, Locale locale) {
          ResourceBundle bundle = getResourceBundle(basename, locale);
          return bundle.keySet();
      }
  
  }
  </code></pre>
  
  <p>I have 2 problems with this:</p>
  
  <p><strong>Problem 1:</strong>
  My message files are located under WEB-INF/i18n directory. It contains only 2 files: messages_en.properties and messages_hr.properties. </p>
  
  <p>If I try to run the above code I'm getting warning: 
  "ResourceBundle [messages] not found for MessageSource: Can't find bundle for base name messages, locale 'some locale'", followed by NullPointerException. </p>
  
  <p>If I move messages files to WEB-INF/classes folder problem disappears however I get 2nd problem. </p>
  
  <p><strong>Problem 2:</strong>
  If I run the code above while messages are under WEB-INF/classes directory I'm getting exception: "No message found under code 'some.code' for locale 'some locale'" even thou all keys are loaded correctly.</p>
  
  <p>Question is: how to avoid problem no.1 by keeping messages inside WEB-INF/i18n folder and I need a solution for 2nd problem because I really have no idea what's going on there. </p>