commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adam kramer <>
Subject [BEANUTILS] BeanUtils.copyProperty: IllegalArgumentException
Date Wed, 11 Dec 2002 17:17:07 GMT

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(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(
at org.apache.commons.beanutils.BeanUtils.copyProperty(

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;

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.

Adam Kramer

View raw message