Struts: Missing message for key...

Discussion in 'Java' started by Darrin, Jan 20, 2004.

  1. Darrin

    Darrin Guest

    I keep getting a "Missing message for key..." error. Here is what the
    application setup is:

    1) I have an ApplicationResources.properties file located here:
    \WEB-INF\classes\com\company\product\appname\ApplicationResources.properties

    2) In my web.xml file I have the following entry:

    <!-- Action Servlet Configuration -->
    <servlet>
    <servlet-name>appname</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
    <param-name>application</param-name>
    <param-value>com.company.product.appname.ApplicationResources</param-value>
    </init-param>



    3) In that ApplicationResources.properties file I have the following:
    image.company=Company Name

    4) My .jsp that requests the key is in the top level directory (same
    level as WEB-INF). In that file I have this:
    img src="Company_Logo.gif" align="left" alt="<bean:message
    key="image.company"/>"

    When I try to load it, I get: Missing message for key "image.company"
    javax.servlet.jsp.JspException: Missing message for key
    "image.company" at org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:297)
    at...

    This is driving me crazy! I've tried copying the Application.Resources
    file to every directory I could think of but nothing helps.

    What am I doing wrong? All I could find on the net is this:
    The key-value pair with specified key is not in
    ApplicationResources.properties file

    or

    ApplicationResources.properties file not in classpath (not in
    WEB-INF/classes directory in specified location)

    Well, it is specified, and it is in the classpath.

    Someone please tell me what I'm doing wrong!

    Thanks!
    Darrin, Jan 20, 2004
    #1
    1. Advertising

  2. Darrin

    Sudsy Guest

    Darrin wrote:
    > I keep getting a "Missing message for key..." error. Here is what the
    > application setup is:
    >
    > 1) I have an ApplicationResources.properties file located here:
    > \WEB-INF\classes\com\company\product\appname\ApplicationResources.properties
    >
    > 2) In my web.xml file I have the following entry:
    >
    > <!-- Action Servlet Configuration -->
    > <servlet>
    > <servlet-name>appname</servlet-name>
    > <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    > <init-param>
    > <param-name>application</param-name>
    > <param-value>com.company.product.appname.ApplicationResources</param-value>
    > </init-param>


    You're missing the following, which should go in your struts-config.xml
    file:
    <message-resources null="true" parameter="ApplicationResources"/>

    Make sure that you put it in the right place according to the TLD. It
    should appear after the <controller> tag and before and <plug-in>s.
    Sudsy, Jan 21, 2004
    #2
    1. Advertising

  3. Darrin

    esaiesai

    Joined:
    Apr 22, 2010
    Messages:
    1
    Same issue I faced,....but then realized that the message resource file name should be mentioned in the web.xml with out the extension.

    So, for example,

    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>com........AppControllerServlet</servlet-class>

    <init-param>
    <param-name>config</param-name>
    <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>

    <init-param>
    <param-name>application</param-name>
    <param-value>AppErrorMessages</param-value>
    </init-param>

    Here, "AppErrorMessages" should not be mentioned as "AppErrorMessages.properties".
    esaiesai, Apr 22, 2010
    #3
  4. Darrin

    ahil23

    Joined:
    Jul 21, 2011
    Messages:
    1
    Tht's great...
    Actually i was searching google for this error.
    And after seeing the velocity Reviews i did the denoted things in the web.xml and struts-config.xml.
    Now its working...
    ahil23, Jul 21, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hari Om
    Replies:
    3
    Views:
    12,142
    Wendy S
    Oct 1, 2003
  2. Jason Us
    Replies:
    0
    Views:
    984
    Jason Us
    Oct 4, 2003
  3. Joos Nielsen
    Replies:
    2
    Views:
    1,023
    Ryan Stewart
    Jun 4, 2004
  4. Replies:
    0
    Views:
    772
  5. M P
    Replies:
    1
    Views:
    466
Loading...

Share This Page