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 argument type mismatch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "argument type mismatch" Watch "argument type mismatch" New topic
Author

argument type mismatch

Raj Chukka
Greenhorn

Joined: Apr 09, 2007
Posts: 22
Hi
iam getting the following exception when iam checking the "checkbox" click event.

[5/9/08 11:47:53:047 EDT] 7cbab2f0 WebGroup E SRVE0026E: [Servlet Error]-[BeanUtils.populate]: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
at org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
at org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:983)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)


iam using a form bean which has an arraylist (collection of DTOs) because i need to display a list and that "DTO" has one more arraylist (i need to display list inside list) inside.

Can someone exlain me why iam getting this issue? Is it legal to use like this?

Thanks,
Rajendra
Vishal Matere
Ranch Hand

Joined: Jan 22, 2008
Posts: 81
can you please post your ActionForm, Bean and JSP ?

Most likely you haven't defined a setter method for checkbox attribute in ActionForm or you may have created setter method with incorrect signature.


SCJP <br />SCWCD <br />SCBCD <br />SCEA-1
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
ActionForm properties accessed directly in a non-indexed way must be Strings. This is likely why you're getting this error: You may have tried to access an ArrayList in a non-indexed way. See question 11 of this forum's FAQ


Merrill
Consultant, Sima Solutions
Raj Chukka
Greenhorn

Joined: Apr 09, 2007
Posts: 22
Thanks Merrill.

Though i have collection (arraylist) still iam using the strings inside the DTO.

Iam posting the classes again.

public class DetailFormBean {

ArrayList tempList1; // collection of list objects (dto's)

}

public class DisplayDto {

String strName1; // read/write
String strName2; // read/write
ArrayList tempList2; // collection of inner list (dtos).
}

public class DisplayDto1 {

String s1; // read-only
String s2; // read-only
String s3; // read-only
}

In the JSP iam rendering the page like below.


<logic:notEmpty name="DetailFormBean "
property="tempList1">
<logic:iterate id="list1"
name="DetailFormBean "
property="tempList1"
type="DisplayDto"
indexId="index1">

....


<logic:iterate id="list2"
name="list1"
property="tempList2"
type="DisplayDto"
indexId="index2">

....

</logic:iterate>
</logic:iterate>
</logic:notEmpty>

If i have to do indexing how should i do it here?

Thanks in advance.

Thanks,
raj chukka
Vishal Matere
Ranch Hand

Joined: Jan 22, 2008
Posts: 81
what name you are using for 'checkbox'.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I believe the problem is with this line:

You've told us that the elements in list1 are also a list, yet the above statement says they are of type DisplayDto. This can't be correct, since you're trying to iterate over these elements.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: argument type mismatch
 
Similar Threads
IllegalArgumentException : <html:select>
java.util.Date vs java.sql.Date
how to pass object from jsp to action class in struts???
ServletException BeanUtils populate
java.lang.Illegal Argument Exception: argument type mismatch