File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.st Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.st" Watch "java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.st" New topic
Author

java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.st

kuamit kumar
Greenhorn

Joined: Jul 15, 2009
Posts: 1
hi ,

I am trying to validate my page for null value , it is giving following error ...Please suggest ASAP

java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError
org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
org.apache.jsp.login_jsp._jspx_meth_html_005ferrors_005f0(login_jsp.java:139)
org.apache.jsp.login_jsp._jspx_meth_html_005fhtml_005f0(login_jsp.java:109)
org.apache.jsp.login_jsp._jspService(login_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
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.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

my Form is
public class LoginForm extends ActionForm {

private String userName="";
private String password="";
private String email="";
private int age=0;

public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}


public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}

public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors err = new ActionErrors();
if (userName == null || "".equals(userName)) {
err.add(userName, new ActionMessage("error.userName.required"));
}
if (password == null || "".equals(password)) {
err.add(password, new ActionMessage("error.password.required"));
}
return err;
}

public void reset(ActionMapping mapping, HttpServletRequest request){
userName=null;
password=null;
}
}

and jsp page is
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<html:html>

<head>
<title>Login Page</title>
</head>
<body>

<html:errors/>


<html:form action="/Login">

User Name :<html:text name="LoginForm" property="userName" /> <br>

Password :<html:password name="LoginForm" property="password" /><br>

<html:submit value="Login" />

</html:form>
</body>
</html:html>

please suggest, if anybody has some idea .Thanks!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.st
 
Similar Threads
please help me error comes on my struts application see the source code for details
Problem while running struts application
when iam running my struts application following error comes please help me
error comes while running the struts application please see the source code for detail
tomcat cannot display jsp struts