• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Missing message for key

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I'm new to Struts. I was trying to run an example from Struts-The Complete Reference by James Holmes. I'm getting the following error.

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Missing message for key "label.search.name"
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.search_jsp._jspService(org.apache.jsp.search_jsp:228)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.servlet.jsp.JspException: Missing message for key "label.search.name"
org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:233)
org.apache.jsp.search_jsp._jspx_meth_bean_message_0(org.apache.jsp.search_jsp:312)
org.apache.jsp.search_jsp._jspx_meth_html_form_0(org.apache.jsp.search_jsp:267)
org.apache.jsp.search_jsp._jspService(org.apache.jsp.search_jsp:103)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.
-----------------------------------------------------
Here is my directory structure

MiniHR
|
|
index.jsp
search.jsp
WEB-INF
|
|
web.xml
struts-config.xml
lib(all jar files)
classes
|
|
ApplicationResources.properties
com
|
MiniHR
|
struts(all .class files)

----------------------------------------------------

Here is the deployment descriptor web.xml

<?xml version="1.0"?>

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<!-- Action Servlet Configuration -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<!-- The Welcome File List -->
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>

<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>

</web-app>

-------------------------------------------------------

Here is the configuration file struts-config.xml

<?xml version="1.0"?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>

<!-- Form Beans Configuration -->
<form-beans>
<form-bean name="searchForm"
type="com.MiniHR.struts.SearchForm"/>
</form-beans>

<!-- Global Forwards Configuration -->
<global-forwards>
<forward name="search" path="/search.jsp"/>
</global-forwards>

<!-- Action Mappings Configuration -->
<action-mappings>
<action path="/search"
type="com.MiniHR.struts.SearchAction"
name="searchForm"
scope="request"
validate="true"
input="/search.jsp">
</action>
</action-mappings>

<!-- Message Resources Configuration -->
<message-resources parameter="ApplicationResources"/>

</struts-config>
-----------------------------------------------
Here is my ApplicationResources.properties
# Label Resources
label.search.name=Name
label.search.ssNum=Social Security Number

# Error Resources
error.search.criteria.missing=<li>Search Criteria Missing</li>
error.search.ssNum.invalid=<li>Invalid Social Security Number</li>
errors.header=<font color="red"><b>Validation Error(s)</b></font><ul>
errors.footer=</ul><hr width="100%" size="1" noshade="true">

I don't know where I'm going wrong. Please help.
[ January 27, 2006: Message edited by: Lalitha Vydyula ]
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What this message is trying to tell you is that somewhere in your JSP, you made a reference to the message key "label.search.name", and that Struts can't find that key in your ApplicationResources.properties file.

Make sure the following entry:

label.search.name=some text

is in a file named ApplicationResources.properties, and that this file is in yourApplication/WEB-INF/classes directory.
[ January 27, 2006: Message edited by: Merrill Higginson ]
 
Lalitha Vydyula
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill,
I already have label.search.name=Name , included in my ApplicationResources.properties file & that file is in
MiniHR/WEB-INF/classes folder. Here is my search.jsp file in which I referenced the key label.search.name

 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Everything looks Ok. Have you tried restarting the application server and redeploying the application? Changes to the ApplicationResources.properties file will not take effect until the application is restarted.
 
Lalitha Vydyula
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I tried that too. Still getting the same error.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One other thing to check: Make sure your struts.jar file is in WEB_INF/lib directory and nowhere else.

See this thread.
 
Lalitha Vydyula
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry its my mistake, I named the file as ApplicationProperties.properties and was referecing it a ApplicationResources in configuration file. Its working now. But anyway thanks for trying Merrill.
[ January 27, 2006: Message edited by: Lalitha Vydyula ]
 
Lalitha Vydyula
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I thought that its the name of the file. I changed the name to ApplicationResources but I forgot to change the template text(static test) in the .jsp file.That why it was running before. Now I'm trying to run the application its not working. Its giving the same error. I have struts.jar in the WEB-INF/classes/lib folder.

What could be wrong?

-Lalitha
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I changed the name to ApplicationResources but I forgot to change the template text(static test) in the .jsp file.That why it was running before.



I'm a little confused here. What do you mean by "change the template text (static test)". If it was working, why did you change it?

Also, check to see that struts.jar is not anywhere in your Application server's common or shared libraries.
 
Lalitha Vydyula
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'm a little confused here. What do you mean by "change the template text (static test)". If it was working, why did you change it?



What I meant to say was in my search.jsp file I used
<td>Name:</td> - Static text(Name) rather than using
<td><bean:message key="login.search.name"/></td> - Which gets the value of the key "login.search.name" from the ApplicationResources.properties file.

I hope now its clear.
[ January 27, 2006: Message edited by: Lalitha Vydyula ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic