Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Struts and the fly likes java.lang.ClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "java.lang.ClassCastException" Watch "java.lang.ClassCastException" New topic
Author

java.lang.ClassCastException

Harish Maridi
Ranch Hand

Joined: May 20, 2008
Posts: 60
I have a struts form, I assaigned styleId to it.
and I wrote a java script as follows.

function redirectPageTo(tiknum) {
var name = document.getElementById('ApproveForm');
name.tiknum.value = tiknum;
name.submit();
}
It is sumitting the form. But I am getting java.lang.ClassCastException.
java.lang.ClassCastException: com.att.struts.Approvelist.ApprovelistForm
com.att.struts.Approvelist.ApprovelistAction.execute(ApprovelistAction.java:18)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


I am getting from the root cause that the exception is from the action class. But why it is coming and Suggest me any solution for that.

Thankyou.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
This problem is caused by the fact that the ActionForm you're actually receiving as a parameter to the execute method in your Action class is different than the one you are expecting. Look closely at the action mapping you defined for this action in the struts-config.xml file and make sure that the ActionForm class you defined for it matches the one you coded in the Action class.


Merrill
Consultant, Sima Solutions
Harish Maridi
Ranch Hand

Joined: May 20, 2008
Posts: 60
Thankyou very much Merrill...

Awesome java ranch....
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java.lang.ClassCastException
 
Similar Threads
ServletException: BeanUtils.populate
Formbean exception
I am creating a object of actionform in action class ..but error is showing that due to another form
IllegalArgumentException : <html:select>
ForwardAction error