commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adam kramer <a...@monkey.org>
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(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


Mime
View raw message