Announcement Announcement Module
Collapse
No announcement yet.
Message Bundle - No Message Found exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Message Bundle - No Message Found exception

    Hi friends,
    I m getting following exception when trying to use message bundle. I dont know if spring is able to find my message, which is in class folder of app.

    EXCEPTION:
    ===========
    org.springframework.context.NoSuchMessageException : No message found under code 'educationperiod.invalid.leapday.period.day' for locale 'en_US'.
    org.springframework.context.support.DelegatingMess ageSource.getMessage(DelegatingMessageSource.java: 77)
    org.springframework.context.support.AbstractApplic ationContext.getMessage(AbstractApplicationContext .java:630)
    org.springframework.web.servlet.support.RequestCon text.getMessage(RequestContext.java:492)
    org.springframework.web.servlet.support.BindStatus .getErrorMessages(BindStatus.java:172)
    org.springframework.web.servlet.support.BindStatus .<init>(BindStatus.java:125)
    org.springframework.web.servlet.tags.BindTag.doSta rtTagInternal(BindTag.java:115)
    org.springframework.web.servlet.tags.RequestContex tAwareTag.doStartTag(RequestContextAwareTag.java:6 8)
    org.apache.jsp.WEB_002dINF.jsp.main.setupperiod_js p._jspService(org.apache.jsp.WEB_002dINF.jsp.main. setupperiod_jsp:146)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:99)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:325)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:295)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:245)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    org.springframework.web.servlet.view.InternalResou rceView.renderMergedOutputModel



    Above exception occurs when I try to display errors through
    <c:forEach items="${status.errorMessages}" var ="errorMessage">
    <font color=red><c:out value="${errorMessage}" /><br></font>
    </c:forEach>
    .

    My Message bundle
    ==============
    school_en_US.properties
    -----------------------------
    educationperiod.invalid.normalday.period.day = Date cannot be greater than 28 for normal year
    educationperiod.invalid.leapday.period.day = Date cannot be greater than 29 for leap year



    Please kindly help to resolve the issue.
    Thanks !!!

    Aru K

  • #2
    Is your resource bundle defined as message source in your servlet definition?

    Simon

    Comment


    • #3
      Yes friend.

      It is:

      <!-- Message resource declaration -->
      <bean id="messageResource" class="org.springframework.context.support.Resourc eBundleMessageSource">
      <property name="basename">
      <value>school</value>
      </property>
      </bean>


      Please help to solve this issue.

      Thanks,
      Aru K

      Comment


      • #4
        Isn't it supposed to be <bean id="messageSource"

        Comment


        • #5
          I had a similar issue. I used classpath:. I believe that resolved it. And I do believe the id needs to be "messageSource" as already stated.

          Code:
          	<bean id="messageSource"
          		class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
          		<property name="basename" value="classpath:tscart-messages" />
          		<property name="fallbackToSystemLocale" value="false" />
          	</bean>

          Comment


          • #6
            bean &quot;messageSource&quot; loaded in wrong context

            Hi, for me the problem was solved when I moved the "messageSource" definition from the servlet context, e.g. "shippingrate-servlet.xml" to my root context "applicationContext.xml" The reason was that the code was trying to reach the message source in the root context.



            /Peter

            Comment


            • #7
              Perhaps a rather late reaction, but it could be useful to others:
              I had the same problem, and it was due to a classpath problem. There was another messages.properties file on my classpath, which was found before the one in my WEB-INF folder.
              So, cleaning your project, or renaming the file to myapp-messages.properties could do the trick.

              Comment


              • #8
                Hi,

                I had the same problem too. In my case the problem was the use of ReloadableResourceBundleMessageSource in the *-servlet.xml. The problem disappeared when I replace it for ResourceBundleMessageSource.

                Comment


                • #9
                  Hi, I have a similiar problem, I'd appreciate some help with this...
                  I have a messages.properties configured in my applicationContext.xml and it was working fine. Now I get a "No message found under code myCode for locale es_ES" but just with ONE of the messages. All other error message is displayed with no problem.
                  I'm using SpringMVC.

                  Comment


                  • #10
                    &lt;spring:message&gt; tag not finding properties file code

                    Yes, for me it was what Peter Odéus did to solve the problem. I had a login.jsp file that was just outside the WEB-INF directory, so the <spring:message> codes were not being found. I switched the bean call as Junior Member Peter Odéus did to the applicatonContext.xml root spring configuration file and viola, the <spring:message> tag found the code and now I can complete internationalization (i18n) for my project by localizing the login.jsp page.
                    Thanks Peter.........

                    Comment


                    • #11
                      I also had the same issue. early i used ResourceBundleMessageResource. I replaced it in this way.
                      Note : i m using following resouce bundles
                      WEB-INF/classes/resource/myresource.properties
                      WEB-INF/classes/resource/myresource_es.properties

                      <bean id="messageSource" class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
                      <property name="basenames">
                      <list>
                      <value>classpath:resources/myresource</value>
                      </list>
                      </property>
                      </bean>

                      Comment


                      • #12
                        I am facing issue while loading locale specific file.
                        Log message that I would see is

                        - Loading properties [Messages.properties]
                        - No properties file found for [classpath:resource/messagebundle/Messages_en_us] - neither plain properties nor XML

                        Here is the configuration file.

                        <bean id="messageSource" class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
                        <property name="basenames" value="classpath:resource/messagebundle/Messages" />
                        <property name="fallbackToSystemLocale" value="false" />
                        </bean>

                        Am I missing some configuration?
                        Any help would be greate.

                        Thanks
                        GB

                        Comment


                        • #13
                          I got it.
                          There is was an issue of "_US" and "_us".
                          If I remove <property name="fallbackToSystemLocale" value="false" /> from configuration it will check for all combinations like "_en", "_en_us", "_en_US" etc.
                          But if I keep that configuration it will looks for specific "_en_us" and will fail if not found.

                          Cheers
                          GB

                          Comment


                          • #14
                            Place the .properties file

                            Hi Friends

                            place your .properties (ex.. message.properties) in you src directory

                            src/yourpackage/yourprogram.java
                            src/message.properties
                            Last edited by deepaksurthi; Aug 12th, 2010, 06:34 AM.

                            Comment


                            • #15
                              I finally got it , adding

                              "<property name="fallbackToSystemLocale" value="false" />"

                              but now , the labels don't change . Here is my conf :

                              <!-- Configuracion de mensajes - internacionalizacion -->
                              <bean id="messageSource"
                              class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
                              <property name="basename" value="classpath:message" />
                              <property name="fallbackToSystemLocale" value="false" />
                              </bean>

                              <bean id="localeResolver"
                              class="org.springframework.web.servlet.i18n.Sessio nLocaleResolver">
                              <property name="defaultLocale" value="es" />
                              </bean>

                              <bean id="localeChangeInterceptor"
                              class="org.springframework.web.servlet.i18n.Locale ChangeInterceptor">
                              <property name="paramName" value="lang" />
                              </bean>

                              <bean id="handlerMapping"
                              class="org.springframework.web.servlet.mvc.annotat ion.DefaultAnnotationHandlerMapping">
                              <property name="interceptors">
                              <ref bean="localeChangeInterceptor" />
                              </property>
                              </bean>

                              No exception (this problem it's solved), so I guess it finds the files, but I have no change in the labels. My files are in

                              /src/main/resources/message_en.properties
                              /src/main/resources/message_es.properties

                              any clue (thanks in advance) ??

                              Comment

                              Working...
                              X