You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nathan Maves <Na...@Sun.COM> on 2004/05/14 21:30:13 UTC

BeanUtils.copyProperties IllegalArument Excpetion?

I am getting this error...

java.lang.IllegalArgumentException: argument type mismatch
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at  
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav 
a:39)
         at  
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor 
Impl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at  
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUti 
ls.java:1789)
         at  
org.apache.commons.beanutils.BeanUtils.copyProperty(BeanUtils.java:450)
         at  
org.apache.commons.beanutils.BeanUtils.copyProperties(BeanUtils.java: 
239)
         at  
reporting.viewer.presentation.actions.ReportDispatch.update(ReportDispat 
ch.java:45)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at  
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav 
a:39)
	...

When I copy a DynaActionForm to my class.  Strange thing is that I just  
did the reverse and it worked.

Code that works ...

Report report = (Report) tree.findNode(node);
DynaActionForm dForm = (DynaActionForm)form;
BeanUtils.copyProperties(dForm, report);

Code that breaks ...

DynaActionForm dForm = (DynaActionForm) form;
Report report = new Report();
BeanUtils.copyProperties(report, dForm);

Here is the form bean ...

<form-bean name="reportForm"  
type="org.apache.struts.action.DynaActionForm">
             <form-property name="name" type="java.lang.String"/>
             <form-property name="id" type="java.lang.String"/>
             <form-property name="description" type="java.lang.String"/>
             <form-property name="archive" type="java.lang.Boolean"  
initial="false"/>
             <form-property name="brioJobId" type="java.lang.String"/>
             <form-property name="type" type="java.lang.String"/>
             <form-property name="postedDate" type="java.lang.String"/>
             <form-property name="frequency" type="java.lang.String"/>
</form-bean>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: BeanUtils.copyProperties IllegalArument Excpetion?

Posted by Colin Kilburn <co...@accesstec.ca>.
In my experience this works fine.

Colin

Nathan Maves wrote:

> That was it!
>
> What is the best way to set a date field as a hidden property?
>
> Will is just work if I use <html:hidden and a date property?
>
> Nathan
>
> On May 14, 2004, at 2:10 PM, Colin Kilburn wrote:
>
>> Hi Nathan,
>>
>> I had this (or a similar) problem when I tried to populate a date  
>> field.   It seems that a null or empty String is not a valid value 
>> for  conversion to a Date.   I remember the issue having something to 
>> do  with BeanUtils' converter not having a default value for 
>> Date.        Any chance this is the case?
>>
>> Colin
>>
>> Nathan Maves wrote:
>>
>>> I am getting this error...
>>>
>>> java.lang.IllegalArgumentException: argument type mismatch
>>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>         at   
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j 
>>> av a:39)
>>>         at   
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess 
>>> or Impl.java:25)
>>>         at java.lang.reflect.Method.invoke(Method.java:324)
>>>         at   
>>> org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyU 
>>> ti ls.java:1789)
>>>         at   
>>> org.apache.commons.beanutils.BeanUtils.copyProperty(BeanUtils.java: 
>>> 450)
>>>         at   
>>> org.apache.commons.beanutils.BeanUtils.copyProperties(BeanUtils.java:  
>>> 239)
>>>         at   
>>> reporting.viewer.presentation.actions.ReportDispatch.update(ReportDisp 
>>> at ch.java:45)
>>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>         at   
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j 
>>> av a:39)
>>>     ...
>>>
>>> When I copy a DynaActionForm to my class.  Strange thing is that I  
>>> just  did the reverse and it worked.
>>>
>>> Code that works ...
>>>
>>> Report report = (Report) tree.findNode(node);
>>> DynaActionForm dForm = (DynaActionForm)form;
>>> BeanUtils.copyProperties(dForm, report);
>>>
>>> Code that breaks ...
>>>
>>> DynaActionForm dForm = (DynaActionForm) form;
>>> Report report = new Report();
>>> BeanUtils.copyProperties(report, dForm);
>>>
>>> Here is the form bean ...
>>>
>>> <form-bean name="reportForm"   
>>> type="org.apache.struts.action.DynaActionForm">
>>>             <form-property name="name" type="java.lang.String"/>
>>>             <form-property name="id" type="java.lang.String"/>
>>>             <form-property name="description"  
>>> type="java.lang.String"/>
>>>             <form-property name="archive" type="java.lang.Boolean"   
>>> initial="false"/>
>>>             <form-property name="brioJobId" type="java.lang.String"/>
>>>             <form-property name="type" type="java.lang.String"/>
>>>             <form-property name="postedDate" type="java.lang.String"/>
>>>             <form-property name="frequency" type="java.lang.String"/>
>>> </form-bean>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: BeanUtils.copyProperties IllegalArument Excpetion?

Posted by Nathan Maves <Na...@Sun.COM>.
That was it!

What is the best way to set a date field as a hidden property?

Will is just work if I use <html:hidden and a date property?

Nathan

On May 14, 2004, at 2:10 PM, Colin Kilburn wrote:

> Hi Nathan,
>
> I had this (or a similar) problem when I tried to populate a date  
> field.   It seems that a null or empty String is not a valid value for  
> conversion to a Date.   I remember the issue having something to do  
> with BeanUtils' converter not having a default value for Date.        
> Any chance this is the case?
>
> Colin
>
> Nathan Maves wrote:
>
>> I am getting this error...
>>
>> java.lang.IllegalArgumentException: argument type mismatch
>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>         at   
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j 
>> av a:39)
>>         at   
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess 
>> or Impl.java:25)
>>         at java.lang.reflect.Method.invoke(Method.java:324)
>>         at   
>> org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyU 
>> ti ls.java:1789)
>>         at   
>> org.apache.commons.beanutils.BeanUtils.copyProperty(BeanUtils.java: 
>> 450)
>>         at   
>> org.apache.commons.beanutils.BeanUtils.copyProperties(BeanUtils.java:  
>> 239)
>>         at   
>> reporting.viewer.presentation.actions.ReportDispatch.update(ReportDisp 
>> at ch.java:45)
>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>         at   
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j 
>> av a:39)
>>     ...
>>
>> When I copy a DynaActionForm to my class.  Strange thing is that I  
>> just  did the reverse and it worked.
>>
>> Code that works ...
>>
>> Report report = (Report) tree.findNode(node);
>> DynaActionForm dForm = (DynaActionForm)form;
>> BeanUtils.copyProperties(dForm, report);
>>
>> Code that breaks ...
>>
>> DynaActionForm dForm = (DynaActionForm) form;
>> Report report = new Report();
>> BeanUtils.copyProperties(report, dForm);
>>
>> Here is the form bean ...
>>
>> <form-bean name="reportForm"   
>> type="org.apache.struts.action.DynaActionForm">
>>             <form-property name="name" type="java.lang.String"/>
>>             <form-property name="id" type="java.lang.String"/>
>>             <form-property name="description"  
>> type="java.lang.String"/>
>>             <form-property name="archive" type="java.lang.Boolean"   
>> initial="false"/>
>>             <form-property name="brioJobId" type="java.lang.String"/>
>>             <form-property name="type" type="java.lang.String"/>
>>             <form-property name="postedDate" type="java.lang.String"/>
>>             <form-property name="frequency" type="java.lang.String"/>
>> </form-bean>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: BeanUtils.copyProperties IllegalArument Excpetion?

Posted by Colin Kilburn <co...@accesstec.ca>.
Hi Nathan,

I had this (or a similar) problem when I tried to populate a date 
field.   It seems that a null or empty String is not a valid value for 
conversion to a Date.   I remember the issue having something to do with 
BeanUtils' converter not having a default value for Date.       Any 
chance this is the case?

Colin

Nathan Maves wrote:

> I am getting this error...
>
> java.lang.IllegalArgumentException: argument type mismatch
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at  
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav 
> a:39)
>         at  
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor 
> Impl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:324)
>         at  
> org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUti 
> ls.java:1789)
>         at  
> org.apache.commons.beanutils.BeanUtils.copyProperty(BeanUtils.java:450)
>         at  
> org.apache.commons.beanutils.BeanUtils.copyProperties(BeanUtils.java: 
> 239)
>         at  
> reporting.viewer.presentation.actions.ReportDispatch.update(ReportDispat 
> ch.java:45)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at  
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav 
> a:39)
>     ...
>
> When I copy a DynaActionForm to my class.  Strange thing is that I 
> just  did the reverse and it worked.
>
> Code that works ...
>
> Report report = (Report) tree.findNode(node);
> DynaActionForm dForm = (DynaActionForm)form;
> BeanUtils.copyProperties(dForm, report);
>
> Code that breaks ...
>
> DynaActionForm dForm = (DynaActionForm) form;
> Report report = new Report();
> BeanUtils.copyProperties(report, dForm);
>
> Here is the form bean ...
>
> <form-bean name="reportForm"  
> type="org.apache.struts.action.DynaActionForm">
>             <form-property name="name" type="java.lang.String"/>
>             <form-property name="id" type="java.lang.String"/>
>             <form-property name="description" type="java.lang.String"/>
>             <form-property name="archive" type="java.lang.Boolean"  
> initial="false"/>
>             <form-property name="brioJobId" type="java.lang.String"/>
>             <form-property name="type" type="java.lang.String"/>
>             <form-property name="postedDate" type="java.lang.String"/>
>             <form-property name="frequency" type="java.lang.String"/>
> </form-bean>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org