Struts: Missing message for key...

D

Darrin

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!
 
S

Sudsy

Darrin said:
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.
 
Joined
Apr 22, 2010
Messages
1
Reaction score
0
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".
 
Joined
Jul 21, 2011
Messages
1
Reaction score
0
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...
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top