March 7, 2011

javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE


Topic:  Struts 1.3.8

Application Server: JBoss 4.2.2GA

Exception:


ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE
at org.apache.struts.taglib.TagUtils.retrieveMessageResources(TagUtils.java:1112)
at org.apache.struts.taglib.TagUtils.present(TagUtils.java:1055)
at org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:200)
at org.apache.jsp.login_jsp._jspx_meth_html_005ferrors_005f0(login_jsp.java:156)
at org.apache.jsp.login_jsp._jspx_meth_html_005fform_005f0(login_jsp.java:112)
at org.apache.jsp.login_jsp._jspService(login_jsp.java:77)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)



Resolution:

To resolve this error, first add a message resources bundle (a .properties file) to the Struts-enabled web application - the file should be placed in the classpath of the application.

Next, configure the file information in the struts-config.xml Struts configuration file, by adding the <message-resources> element as below,

<message-resources parameter="resources.ApplicationResources" />

where resources.ApplicationResources is the fully-qualified name (reflecting the package structure) of the file ApplicationResources.properties (the .properties extension is not required in the configuration).

1 comment:

  1. thanks a lot for this info. this really saved me lot of time and its working fine now

    ReplyDelete