This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Action Message error

 
Rochal Collins
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting errors when I try to validate my application.

Here's my struts-config:

<action-mappings>
<action
path="/viewresume"
type="com.struts.resumeonline.SearchAction"
input="/viewresume.jsp"
name="searchForm"
scope="request"
validate="true">
<forward name="success" path="/viewresume" redirect="true" />

</action>
</action-mappings>

form:

public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request)
{
ActionErrors errors = new ActionErrors();
if (getEmail() == null || getEmail().length() < 1) {
errors.add("email", new ActionMessage("error.Search.email.missing"));
}
if (getPassword() == null || getPassword().length() < 1) {
errors.add("password", new ActionMessage("error.Search.password.missing"));
}

return errors;
}
applicationresources file:

# Resources for parameter 'com.struts.resumeonline.ApplicationResources'
# Project ResumeOnline
# Label Resouces
label.Search.email=Email
label.Search.password=Password


#Error Resources
error.Search.criteria.missing=Search Criteria Missing
error.Search.email.missing=Email Missing
errors.header=<font color="red"><cTypeface:Bold>Validation Error(s)</b></font><ul>
error.footer=</ul><hr width="100%" size="1" noshade="true">
errors.prefix=<li>
errors.suffix=</li>


Here's the errors:

org.apache.jasper.JasperException: org.apache.struts.action.ActionMessage
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:476)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

java.lang.ClassCastException: org.apache.struts.action.ActionMessage
org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
org.apache.jsp.viewresume_jsp._jspx_meth_html_005ferrors_005f0(viewresume_jsp.java:357)
org.apache.jsp.viewresume_jsp._jspService(viewresume_jsp.java:106)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

What am I doing wrong?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only thing I can suggest would be to make sure that all jar files in your WEB-INF/lib file come from the download for the same version of Struts -- no mixing and matching from different versions. If you're using Struts 1.3.x, make sure you remove all TLD files and use the new namespace references rather than the old type. For example, this should be your taglib definition for html tags:
 
Rochal Collins
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Merill. I figured it out early this morning. That was the problem!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic