• 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

java.lang.IllegalArgumentException: argument type mismatch

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I m using Struts 1.2 with jboss

I have used <html:optionsCollection> tag in my form and loading values from database at form load.
While loading the form it will not show any error but when i submitting that form then showing the following error


HTTP Status 500 -

type Exception report

message

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

exception

javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
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:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:416)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)

root cause

java.lang.IllegalArgumentException: argument type mismatch
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
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:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:416)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
Apache Tomcat/5.0.28


I have wrriten session scope in the struts-config file.
Whats the reason?

 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show us your form bean and jsp page. This tutorial might help to figure out your error...
 
vrushali chaskar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jsp page

FormNo2.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="/tlds/c.tld" prefix='c'%>
<%@ taglib uri="/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/tlds/struts-html.tld" prefix="html" %>
<%@ taglib prefix="s" uri="/tlds/struts-tags.tld" %>

<html>



<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Budget Form 2</title>
<head>
<html:javascript formName="formNo2"/>

<LINK rel="stylesheet" type="text/css" href="/Gramlekha/css/CalendarControl.css">
</head>
<body>
<html:form action="/Form2" onsubmit="return validateFormNo2(this);">

<div>
<table>
<tbody>
<tr>
<td align="center"><b><bean:message key="label.budget.header"/></b></td>
</tr>
<tr>
<td>

<fieldset>
<legend style="font-size:13px"><b><bean:message key="label.budget.information"/></b>
</legend>
<table border="0" width="100%" cellpadding="5" cellspacing="5" style="font-size: 13px">
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td><bean:message key="label.budget.date"/><b><font color="red">*</font></b>
<html:text property="budgetdate" readonly="true" onfocus="showCalendarControl(this);"></html:text>
</td>
<td><bean:message key="label.budget.tharavno"/><b><font color="red">*</font></b>
<html:text property="tharavno"></html:text>
</td>
</tr>

</table>
</fieldset></td>
</tr>
<tr>
<td><div>
<fieldset>
<legend style="font-size:13px"><b><bean:message key="label.budget.otherinfo"></bean:message></b></legend>

<table border="1" width="100%" cellspacing="0" cellpadding="5" style="font-size: 13px">
<tr>
<td rowspan="2" align="center"><bean:message key="label.budget.srno"/></td>
<td rowspan="2" align="center"><bean:message key="label.budget.mainpoint"/></td>
<td colspan="2" align="center"><bean:message key="label.budget.budgetpoint"/></td>
<td colspan="2" align="center"><bean:message key="label.budget.from"/></td>
<td colspan="5" align="center"><bean:message key="label.budget.to"/></td>
</tr>
<tr>
<td align="center"><bean:message key="label.budget.pointno"/></td>
<td align="center"><bean:message key="label.budget.amount"/></td>
<td align="center"><bean:message key="label.budget.worketc"/></td>
<td align="center"><bean:message key="label.budget.availableamount"/></td>
<td align="center"><bean:message key="label.budget.mainpoint"/></td>
<td align="center"><bean:message key="label.budget.subpoint"/></td>
<td align="center"><bean:message key="label.budget.worketc"/></td>
<td align="center"><bean:message key="label.budget.amount"/></td>
<td align="center"><bean:message key="label.budget.remark"/></td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">2<br><b><font color="red">*</font></b></td>
<td align="center">3</td>
<td align="center">4</td>
<td align="center">5</td>
<td align="center">6</td>
<td align="center">7 <br><b><font color="red">*</font></b></td>
<td align="center">8</td>
<td align="center">9</td>
<td align="center">10</td>
<td align="center">11</td>
</tr>
<tr>
<td> </td>
<td>
<html:select property="selectedItem">
<html:optionsCollection value="id" name="formNo2Dispatch" label="name" property="budgetHeadListMain"/>
</html:select>
</td>
<td>
<html:text property="matterno" size="5"></html:text>
</td>
<td>
<html:text property="budgetamount" size="5"></html:text>
</td>
<td>
<html:textarea property="workfacilitydetails" cols="10"></html:textarea>
</td>
<td>
<html:text property="remainingamount" size="5"></html:text>
</td>
<td>
<html:select property="selectedItemSub">
<html:optionsCollection value="id" name="formNo2Dispatch" label="name" property="budgetHeadListSub"/>
</html:select>
</td>
<td>
<html:text property="subpoint" size="5"></html:text>
</td>
<td>
<html:textarea property="workfacilitydetailsupto" cols="10"></html:textarea>
</td>
<td>
<html:text property="amount" size="5"></html:text>
</td>
<td>
<html:text property="remark" size="15"></html:text>
</td>
</tr>
</table>
</fieldset>
</div>
</td>
</tr>
<tr>
<td>
<html:submit value="Submit"></html:submit>
</td>
</tr>
</tbody>
</table>
</div>

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


Action Form for the above foem is

package com.gramlekha.budget.ActionForm;

import java.util.ArrayList;
import java.util.Date;

import org.apache.struts.action.ActionForm;

public class FormNo2Form extends ActionForm{

//private ArrayList budgetexpendlist=null;

Date budgetdate;
String tharavno;
String budgetexpend;
Integer matterno;
Integer budgetamount;
String workfacilitydetails;
Integer remainingamount;
String subpoint;
String workfacilitydetailsupto;
Integer amount;
String remark;
String selectedItem;
String selectedItemSub;


public String getSelectedItemSub() {
return selectedItemSub;
}

public void setSelectedItemSub(String selectedItemSub) {
this.selectedItemSub = selectedItemSub;
}

public String getSelectedItem() {
return selectedItem;
}

public void setSelectedItem(String selectedItem) {
this.selectedItem = selectedItem;
}



public String getTharavno(){
return tharavno;
}

public Date getBudgetdate() {
return budgetdate;
}

public void setBudgetdate(Date budgetdate) {
this.budgetdate = budgetdate;
}

public Integer getMatterno() {
return matterno;
}

public void setMatterno(Integer matterno) {
this.matterno = matterno;
}

public Integer getBudgetamount() {
return budgetamount;
}

public void setBudgetamount(Integer budgetamount) {
this.budgetamount = budgetamount;
}

public String getWorkfacilitydetails() {
return workfacilitydetailsupto;
}

public void setWorkfacilitydetails(String workfacilitydetails) {
this.workfacilitydetails = workfacilitydetails;
}

public Integer getRemainingamount() {
return remainingamount;
}

public void setRemainingamount(Integer remainingamount) {
this.remainingamount = remainingamount;
}

public String getSubpoint() {
return subpoint;
}

public void setSubpoint(String subpoint) {
this.subpoint = subpoint;
}

public String getWorkfacilitydetailsupto() {
return workfacilitydetailsupto;
}

public void setWorkfacilitydetailsupto(String workfacilitydetailsupto) {
this.workfacilitydetailsupto = workfacilitydetailsupto;
}

public Integer getAmount() {
return amount;
}

public void setAmount(Integer amount) {
this.amount = amount;
}

public String getRemark() {
return remark;
}

public void setRemark(String remark) {
this.remark = remark;
}

public void setTharavno(String tharavno){
this.tharavno=tharavno;
}

public String getBudgetexpend(){
return budgetexpend;
}

public void setBudgetexpend(String budgetexpend){
this.budgetexpend=budgetexpend;
}

}


Getter setter method for the value and label

package com.gramlekha.bean;


public class BudgetheadBean {

private Integer id;
private String name;


public BudgetheadBean(){

}

public BudgetheadBean(Integer id,String name){
this.id=id;
this.name=name;

}

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getLabel(){
return name;
}

public Integer getValue(){
return id;
}
}



And the Actual class to retrieve values from datatase and set it to the combo

package com.gramlekha.Common;

public class budgetList extends DispatchAction{

String head;

Session session=null;
Transaction tx=null;
String target;

SessionManagement sessionManagement = new SessionManagement();
List <Vouchermaster> detailHeadList= new ArrayList<Vouchermaster>();

public ActionForward prepareList(ActionMapping mapping,
ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception{

try{
session=HibernateSessionFactory.getSession();
tx=session.beginTransaction();

Form2 form2form=(Form2) form;

ArrayList<BudgetheadBean> budgetheads=new ArrayList<BudgetheadBean>();

// Retrieve values from database

List <Vouchermaster> list=session.createQuery("select vm from Vouchermaster as vm").list();

// Create list with database values and strore in array

for (Iterator iter = list.iterator(); iter.hasNext();) {
detailHeadList.add((Vouchermaster)iter.next());
}

for(int i=0;i<detailHeadList.size();i++){
Vouchermaster d =detailHeadList.get(i);
if (d.getBudgethead().length()>50){
head=d.getBudgethead().substring(0, 49).toString();
}else{
head=d.getBudgethead().toString();
}
budgetheads.add(new BudgetheadBean(d.getBudgetcode(),head));

}

// set values to form no 2 from Tab "Budget"
form2form.setBudgetHeadListMain(budgetheads);
form2form.setBudgetHeadListSub(budgetheads);


target="success";


}catch(Exception e){

System.out.println("Error Occured...1");
e.printStackTrace();
target="failure";
}

return mapping.findForward(target);

}


 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please Use Code Tags as it is almost impossible to read your code. Also I'm not sure but maybe your setSelectedItemSub method needs to take a String[] as parameter...
 
Thank you my well lotioned goddess! Here, have my favorite tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic