You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by adam kramer <ad...@monkey.org> on 2002/12/11 18:17:07 UTC
[BEANUTILS] BeanUtils.copyProperty: IllegalArgumentException
I would ultimately like to use the BeanUtils.copyProperties(...)
function, but have been getting this error when even using the
copyProperty func.
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1669)
at org.apache.commons.beanutils.BeanUtils.copyProperty(BeanUtils.java:365)
from this code in a servlet, struts action:
public ActionForward executeAction(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response,
UserContainer userContainer)
throws Exception {
...
Grant grant = new Grant();
GrantForm grantForm = (GrantForm) form;
BeanUtils.copyProperty(grant,"submittedDate",grantForm.getSubmittedDate());
...
}
which is strange, since i can do this in a main() func from the command
line. WITHOUT ANY ERRORS: i can also do copyProperty fine.
static public void main(String s[])
{
Grant grant = new Grant();
GrantForm gf = new GrantForm();
gf.setApplicationType("the one");
System.out.println("grant dir spons id: " + grant.getDirectSponsorId());
BeanUtils.copyProperties(grant, gf);
System.out.println("gr app type: " + grant.getApplicationType());
}
----
There is apparently something wrong with the grant object. The api docs
say that it may be null, but i dont see how that could be since I write
and read from it in my servlet code (not included).
Has anyone experienced similar problems in a servlet context?
any feedback would be great since copyProperties is an indispensible
convenience and timesaver.
thanks,
Adam Kramer