Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8960705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:43:09+00:00 2026-06-15T15:43:09+00:00

In applicationContext.xml I have defined MessageSource like this: <bean id=messageSource class=org.springframework.context.support.ReloadableResourceBundleMessageSource> <property name=basenames> <list>

  • 0

In applicationContext.xml I have defined MessageSource like this:

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basenames">
        <list>
            <value>/WEB-INF/i18n/messages</value>
        </list>
    </property>
</bean>

I also need to load all the localized messages so I have made my own class for it:

public class ErpMessageSource extends ResourceBundleMessageSource {

    public Map<String, String> getMessages(String basename, Locale locale) {
        Set<String> keys = getKeys(basename, locale);
        Map<String, String> m = new HashMap<String, String>();

        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<String> getKeys(String basename, Locale locale) {
        ResourceBundle bundle = getResourceBundle(basename, locale);
        return bundle.keySet();
    }

}

I have 2 problems with this:

Problem 1:
My message files are located under WEB-INF/i18n directory. It contains only 2 files: messages_en.properties and messages_hr.properties.

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.

If I move messages files to WEB-INF/classes folder problem disappears however I get 2nd problem.

Problem 2:
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.

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:43:10+00:00Added an answer on June 15, 2026 at 3:43 pm

    You probably only have to add the resource folder to the classpath of your project.

    Try to do the following operation:

    Right click on the project name in the Package Explorer view —> Properties —> Java Build Path —> stay in the Source tab (opened by default) —> click on Folder —> the list of all the folders inside your project should now appear —> tick on the folder that contains the message properties file

    Rebuild the project and try to run.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Error creating bean with name 'sessionFactory' defined in class path resource [ApplicationContext.xml]: Invocation of
I have an ApplicationContext.xml file with the following node: <context:property-placeholder location=classpath:hibernate.properties, classpath:pathConfiguration.properties /> It
<bean id=sessionFactory class=org.springframework.orm.hibernate3.LocalSessionFactoryBean> <property name=dataSource ref=dataSource/> <property name=mappingResources> <list> <value>product.hbm.xml</value> </list> </property> <property name=hibernateProperties>
Have a JUNIT test set up as such @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({ /applicationContext.xml, /applicationContext-security.xml }) @TransactionConfiguration(defaultRollback
I need the context to ApplicationContext.xml ,which I provided in web.xml as <listener> <listener-class>
In the setup of my test cases, I have this code: ApplicationContext context =
I have a question here, how beans defined in applicationContext.xml could be available to
org.springframework.context.NoSuchMessageException: No message found under code 'user.username.empty' for locale 'en_GB'. Currently I have the
I have a class like this : class User { String name; String password;
I would like to access beans that i have defined in /WEB-INF/springws-servlet.xml from within

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.