Announcement Announcement Module
Collapse
No announcement yet.
MessageSource Configuration Troubleshooting Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MessageSource Configuration Troubleshooting

    Hi,

    I'm trying to retrieve messages using the WebApplicationContext and the ReloadableResourceBundleMessageSource.

    My ReloadableResourceBundleMessageSource configuration looks like this:

    <bean id="messageSource" class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
    <property name="basenames">
    <list>
    <value>com.example.messages</value>
    </list>
    </property>
    <property name="defaultEncoding" value="UTF-8"/>
    </bean>

    I also made sure that the jar containing com.example.messages is included with the webapp packaging and looked inside to see that messages.properties is included and in the package com.example. The properties file messages.properties has the following contents:

    com.example.hello=howdy

    I then try the following call to retrieve the message:

    return webApplicationContext.
    getMessage(
    "com.example.hello",
    null,
    "no message found",
    locale);


    I always get "no message found". Any idea what I'm doing wrong?

    Thanks,
    - Ole

  • #2
    If you add a "classpath:" prefix to your basename I think it should work. With the ReloadableResourceBundleMessageSource it doesn't default to looking in the classpath as reloading only works when the messages file is located outside the classpath e.g. in the WEB-INF folder. Have a look at the information in the javadoc.

    Comment


    • #3
      Ooooh - OK - I thought the ReloadableResourceBundleMessageSource and ResourceBundleMessageSource worked the same way.

      I actually only need the ResourceBundleMessageSource functionality. Now that I'm using that, things are going a lot smoother.

      Thanks also for the classpath tip. I'll put in my little Spring Wizard book :-).

      - Ole

      Comment

      Working...
      X