You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Brian Moseley <bc...@covalent.net> on 2003/02/19 22:02:43 UTC

[beanutils] setProperty problem with indexed nested property

[i posted a similar message to the struts-user list yesterday and 
haven't received a response. i'm posting this one to commons-user since 
it's more likely that the problem is how i'm constructing my property 
name anyway.]

i'm having a problem with a struts ActionForm that has several indexed 
nested properties. when i submit the html page and struts attempts to 
populate the form from the request, BeanUtils.setProperty (or something 
it calls) barfs. i can't tell what the problem is because something is 
annoyingly swallowing the exception.

setProperty is apparently being called with these parameters: 
<PlatformForm instance>, "ip[0].address", <empty String[]> - at least 
that's how it appears to me from examining the log output (below) and 
the trace logging code in setProperty.

i expected that the section of code beginning at line 836 ("//resolve 
any nested expression to get to the actual target bean") would have 
logged "Target bean = ip[0]" and "Target name = address", but that's not 
occurring.

what could i be doing wrong?

the form bean class looks like this (trimmed for brevity):

public class PlatformForm extends ActionForm  {

     private List ip;

     public List getIp() {
	return this.ip;
     }

     public void setIp(List ip) {
         this.ip = ip;
     }

the html that is generated by struts looks like this (also trimmed for 
brevity):

   <tr>
     <td><input type="text" name="ip[0].address" size="30" value=""></td>
     <td><input type="text" name="ip[0].netmask" size="30" value=""></td>
   </tr>

the log file contains this output:

bcm@shrike:~/work/cov/src> 12:30:51,850 INFO  [RequestProcessor] 
Processing a 'POST' for path '/resource/platform/inventory/NewPlatform'
12:30:51,851 DEBUG [RequestProcessor]  Storing ActionForm bean instance 
in scope 'request' under attribute key 'NewPlatformForm'
12:30:51,851 DEBUG [RequestProcessor]  Populating bean properties from 
this request
12:30:51,851 DEBUG [BeanUtils] BeanUtils.populate(startTime=now 
startMonth=null startDay=null startYear=null startHour=00 startMin=00 
startAmPm=am startTimeZone=PST recurInterval=null 
recurrenceFrequencyDaily=everyDay numDays=1 numWeeks=1 
recurrenceDay=[Ljava.lang.Integer;@d11b79 
recurrenceFrequencyMonthly=onDay numMonths=1 recurrenceWeek=null 
eachDay=null endTime=none endMonth=null endDay=null rid=null type=null 
name=null location=null description=null  cpuCount=null cpuSpeed=null 
dhcpServer=null dnsServer=null fqdn=null gateway=null ram=null ip=[], 
{ok.y=[Ljava.lang.String;@62b333, gateway=[Ljava.lang.String;@e2f8c1, 
ip[0].address=[Ljava.lang.String;@3954b1, 
ip[0].MACAddress=[Ljava.lang.String;@e746a2, 
cpuCount=[Ljava.lang.String;@ce56f8, 
dnsServer=[Ljava.lang.String;@afbbe3, 
description=[Ljava.lang.String;@584e97, 
resourceType=[Ljava.lang.String;@8fc7ca, 
ok.x=[Ljava.lang.String;@85bf5f, ram=[Ljava.lang.String;@d733ca, 
location=[Ljava.lang.String;@891d76, 
dhcpServer=[Ljava.lang.String;@ed4d06, fqdn=[Ljava.lang.String;@5bece2, 
name=[Ljava.lang.String;@1cf4e5, cpuSpeed=[Ljava.lang.String;@121e5a, 
ip[0].netmask=[Ljava.lang.String;@86aad9})
12:30:51,851 DEBUG [BeanUtils]   setProperty(startTime=now 
startMonth=null startDay=null startYear=null startHour=00 startMin=00 
startAmPm=am startTimeZone=PST recurInterval=null 
recurrenceFrequencyDaily=everyDay numDays=1 numWeeks=1 
recurrenceDay=[Ljava.lang.Integer;@d11b79 
recurrenceFrequencyMonthly=onDay numMonths=1 recurrenceWeek=null 
eachDay=null endTime=none endMonth=null endDay=null rid=null type=null 
name=null location=null description=null  cpuCount=null cpuSpeed=null 
dhcpServer=null dnsServer=null fqdn=null gateway=null ram=null ip=[], 
ok.y, [16])
12:30:51,852 DEBUG [BeanUtils]     Target bean = false
12:30:51,852 DEBUG [BeanUtils]     Target name = y
12:30:51,852 DEBUG [BeanUtils]   setProperty(startTime=now 
startMonth=null startDay=null startYear=null startHour=00 startMin=00 
startAmPm=am startTimeZone=PST recurInterval=null 
recurrenceFrequencyDaily=everyDay numDays=1 numWeeks=1 
recurrenceDay=[Ljava.lang.Integer;@d11b79 
recurrenceFrequencyMonthly=onDay numMonths=1 recurrenceWeek=null 
eachDay=null endTime=none endMonth=null endDay=null rid=null type=null 
name=null location=null description=null  cpuCount=null cpuSpeed=null 
dhcpServer=null dnsServer=null fqdn=null gateway=null ram=null ip=[], 
gateway, [])
12:30:51,852 DEBUG [ConvertUtils] Convert string '' to class 
'java.lang.String'
12:30:51,852 DEBUG [ConvertUtils]   Using converter 
org.apache.commons.beanutils.converters.StringConverter@be8216
12:30:51,852 DEBUG [BeanUtils]   setProperty(startTime=now 
startMonth=null startDay=null startYear=null startHour=00 startMin=00 
startAmPm=am startTimeZone=PST recurInterval=null 
recurrenceFrequencyDaily=everyDay numDays=1 numWeeks=1 
recurrenceDay=[Ljava.lang.Integer;@d11b79 
recurrenceFrequencyMonthly=onDay numMonths=1 recurrenceWeek=null 
eachDay=null endTime=none endMonth=null endDay=null rid=null type=null 
name=null location=null description=null  cpuCount=null cpuSpeed=null 
dhcpServer=null dnsServer=null fqdn=null gateway= ram=null ip=[], 
ip[0].address, [])


Re: [beanutils] setProperty problem with indexed nested property

Posted by Brian Moseley <bc...@covalent.net>.
i finally tracked down this problem- somewhere within setProperty or 
beneath, my form's getter was being called (as expected) and was 
returning a null value. apparently this was generating a null pointer 
exception which was then being swallowed. i and several of my colleages 
had a hell of a time tracking down the problem. hopefully somebody can 
find where the npe is being swallowed and change the code to do 
something a bit more caller-friendly. thanks.

robert burrell donkin wrote:
> hi Brian
> 
> i've tried to create a test case to see if it's a beanutils bug - but i 
> can't seem to make it break. this might be because this is caused by a 
> bug which has since been fixed, it could be because i don't have enough 
> information to create a good test case which demonstrates the bug - or 
> it could be that there isn't a problem with beanutils.
> 
> if you're not using the latest beanutils version (1.6.1) please upgrade 
> and retry.
> 
> if this doesn't work, then please create a small scale test where you 
> call beanutils.setProperty "ip[0].address" directly on your beans. if 
> this doesn't work, then please distill a test case (which you're happy 
> to contribute to apache) and i'll fix the bug.
> 
> if your problem is still present with 1.6.1 but doesn't manifest itself 
> outside structs then please ask again and we can look at integration 
> issues.
> 
> - robert
> 
> On Wednesday, February 19, 2003, at 09:02 PM, Brian Moseley wrote:
> 
>>
>> [i posted a similar message to the struts-user list yesterday and 
>> haven't received a response. i'm posting this one to commons-user 
>> since it's more likely that the problem is how i'm constructing my 
>> property name anyway.]
>>
>> i'm having a problem with a struts ActionForm that has several indexed 
>> nested properties. when i submit the html page and struts attempts to 
>> populate the form from the request, BeanUtils.setProperty (or 
>> something it calls) barfs. i can't tell what the problem is because 
>> something is annoyingly swallowing the exception.
>>
>> setProperty is apparently being called with these parameters: 
>> <PlatformForm instance>, "ip[0].address", <empty String[]> - at least 
>> that's how it appears to me from examining the log output (below) and 
>> the trace logging code in setProperty.
>>
>> i expected that the section of code beginning at line 836 ("//resolve 
>> any nested expression to get to the actual target bean") would have 
>> logged "Target bean = ip[0]" and "Target name = address", but that's 
>> not occurring.
>>
>> what could i be doing wrong?
>>
>> the form bean class looks like this (trimmed for brevity):
>>
>> public class PlatformForm extends ActionForm  {
>>
>>     private List ip;
>>
>>     public List getIp() {
>>     return this.ip;
>>     }
>>
>>     public void setIp(List ip) {
>>         this.ip = ip;
>>     }
>>
>> the html that is generated by struts looks like this (also trimmed for 
>> brevity):
>>
>>   <tr>
>>     <td><input type="text" name="ip[0].address" size="30" value=""></td>
>>     <td><input type="text" name="ip[0].netmask" size="30" value=""></td>
>>   </tr>
>>
>> the log file contains this output:
>>
>> bcm@shrike:~/work/cov/src> 12:30:51,850 INFO  [RequestProcessor] 
>> Processing a 'POST' for path '/resource/platform/inventory/NewPlatform'
>> 12:30:51,851 DEBUG [RequestProcessor]  Storing ActionForm bean 
>> instance in scope 'request' under attribute key 'NewPlatformForm'
>> 12:30:51,851 DEBUG [RequestProcessor]  Populating bean properties from 
>> this request
>> 12:30:51,851 DEBUG [BeanUtils] BeanUtils.populate(startTime=now 
>> startMonth=null startDay=null startYear=null startHour=00 startMin=00 
>> startAmPm=am startTimeZone=PST recurInterval=null 
>> recurrenceFrequencyDaily=everyDay numDays=1 numWeeks=1 
>> recurrenceDay=[Ljava.lang.Integer;@d11b79 
>> recurrenceFrequencyMonthly=onDay numMonths=1 recurrenceWeek=null eachDay=
>> null endTime=none endMonth=null endDay=null rid=null type=null 
>> name=null location=null description=null  cpuCount=null cpuSpeed=null 
>> dhcpServer=null dnsServer=null fqdn=null gateway=null ram=null ip=[], 
>> {ok.
>> y=[Ljava.lang.String;@62b333, gateway=[Ljava.lang.String;@e2f8c1, 
>> ip[0].address=[Ljava.lang.String;@3954b1, 
>> ip[0].MACAddress=[Ljava.lang.String;@e746a2, cpuCount=[Ljava.lang.String;
>> @ce56f8, dnsServer=[Ljava.lang.String;@afbbe3, 
>> description=[Ljava.lang.String;@584e97, resourceType=[Ljava.lang.String;@
>> 8fc7ca, ok.x=[Ljava.lang.String;@85bf5f, 
>> ram=[Ljava.lang.String;@d733ca, location=[Ljava.lang.String;@891d76, 
>> dhcpServer=[Ljava.lang.String;@ed4d06, 
>> fqdn=[Ljava.lang.String;@5bece2, name=[Ljava.lang.String;@1cf4e5, 
>> cpuSpeed=[Ljava.lang.String;@121e5a, ip[
>> 0].netmask=[Ljava.lang.String;@86aad9})
>> 12:30:51,851 DEBUG [BeanUtils]   setProperty(startTime=now 
>> startMonth=null startDay=null startYear=null startHour=00 startMin=00 
>> startAmPm=am startTimeZone=PST recurInterval=null 
>> recurrenceFrequencyDaily=everyDay numDays=1 numWeeks=1 
>> recurrenceDay=[Ljava.lang.Integer;@d11b79 
>> recurrenceFrequencyMonthly=onDay numMonths=1 recurrenceWeek=null eachDay=
>> null endTime=none endMonth=null endDay=null rid=null type=null 
>> name=null location=null description=null  cpuCount=null cpuSpeed=null 
>> dhcpServer=null dnsServer=null fqdn=null gateway=null ram=null ip=[], ok.
>> y, [16])
>> 12:30:51,852 DEBUG [BeanUtils]     Target bean = false
>> 12:30:51,852 DEBUG [BeanUtils]     Target name = y
>> 12:30:51,852 DEBUG [BeanUtils]   setProperty(startTime=now 
>> startMonth=null startDay=null startYear=null startHour=00 startMin=00 
>> startAmPm=am startTimeZone=PST recurInterval=null 
>> recurrenceFrequencyDaily=everyDay numDays=1 numWeeks=1 
>> recurrenceDay=[Ljava.lang.Integer;@d11b79 
>> recurrenceFrequencyMonthly=onDay numMonths=1 recurrenceWeek=null eachDay=
>> null endTime=none endMonth=null endDay=null rid=null type=null 
>> name=null location=null description=null  cpuCount=null cpuSpeed=null 
>> dhcpServer=null dnsServer=null fqdn=null gateway=null ram=null ip=[], 
>> gateway, [])
>> 12:30:51,852 DEBUG [ConvertUtils] Convert string '' to class 
>> 'java.lang.String'
>> 12:30:51,852 DEBUG [ConvertUtils]   Using converter 
>> org.apache.commons.beanutils.converters.StringConverter@be8216
>> 12:30:51,852 DEBUG [BeanUtils]   setProperty(startTime=now 
>> startMonth=null startDay=null startYear=null startHour=00 startMin=00 
>> startAmPm=am startTimeZone=PST recurInterval=null 
>> recurrenceFrequencyDaily=everyDay numDays=1 numWeeks=1 
>> recurrenceDay=[Ljava.lang.Integer;@d11b79 
>> recurrenceFrequencyMonthly=onDay numMonths=1 recurrenceWeek=null eachDay=
>> null endTime=none endMonth=null endDay=null rid=null type=null 
>> name=null location=null description=null  cpuCount=null cpuSpeed=null 
>> dhcpServer=null dnsServer=null fqdn=null gateway= ram=null ip=[], 
>> ip[0].address, [])
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 



Re: [beanutils] setProperty problem with indexed nested property

Posted by Brian Moseley <bc...@covalent.net>.
robert burrell donkin wrote:
> hi Brian
> 
> i've tried to create a test case to see if it's a beanutils bug - but i 
> can't seem to make it break. this might be because this is caused by a 
> bug which has since been fixed, it could be because i don't have enough 
> information to create a good test case which demonstrates the bug - or 
> it could be that there isn't a problem with beanutils.
> 
> if you're not using the latest beanutils version (1.6.1) please upgrade 
> and retry.
> 
> if this doesn't work, then please create a small scale test where you 
> call beanutils.setProperty "ip[0].address" directly on your beans. if 
> this doesn't work, then please distill a test case (which you're happy 
> to contribute to apache) and i'll fix the bug.
> 
> if your problem is still present with 1.6.1 but doesn't manifest itself 
> outside structs then please ask again and we can look at integration 
> issues.

robert, thanks for the comments. i'm fairly sure that i'm using 1.6.1, 
but i'll verify.

i'm glad to hear that beanutils seems to have the ability to do what i'm 
asking of it. as this is the first time i've worked with indexed nested 
properties, it's very likely that the problem is pilot error; i was just 
hoping that somebody could look at the data i provided and call out an 
obvious problem.

in any case, i will put together a test and then get back to you. thanks 
again.


Re: [beanutils] setProperty problem with indexed nested property

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
hi Brian

i've tried to create a test case to see if it's a beanutils bug - but i 
can't seem to make it break. this might be because this is caused by a bug 
which has since been fixed, it could be because i don't have enough 
information to create a good test case which demonstrates the bug - or it 
could be that there isn't a problem with beanutils.

if you're not using the latest beanutils version (1.6.1) please upgrade 
and retry.

if this doesn't work, then please create a small scale test where you call 
beanutils.setProperty "ip[0].address" directly on your beans. if this 
doesn't work, then please distill a test case (which you're happy to 
contribute to apache) and i'll fix the bug.

if your problem is still present with 1.6.1 but doesn't manifest itself 
outside structs then please ask again and we can look at integration 
issues.

- robert

On Wednesday, February 19, 2003, at 09:02 PM, Brian Moseley wrote:

>
> [i posted a similar message to the struts-user list yesterday and haven't 
> received a response. i'm posting this one to commons-user since it's more 
> likely that the problem is how i'm constructing my property name anyway.]
>
> i'm having a problem with a struts ActionForm that has several indexed 
> nested properties. when i submit the html page and struts attempts to 
> populate the form from the request, BeanUtils.setProperty (or something 
> it calls) barfs. i can't tell what the problem is because something is 
> annoyingly swallowing the exception.
>
> setProperty is apparently being called with these parameters: 
> <PlatformForm instance>, "ip[0].address", <empty String[]> - at least 
> that's how it appears to me from examining the log output (below) and the 
> trace logging code in setProperty.
>
> i expected that the section of code beginning at line 836 ("//resolve any 
> nested expression to get to the actual target bean") would have logged 
> "Target bean = ip[0]" and "Target name = address", but that's not 
> occurring.
>
> what could i be doing wrong?
>
> the form bean class looks like this (trimmed for brevity):
>
> public class PlatformForm extends ActionForm  {
>
>     private List ip;
>
>     public List getIp() {
> 	return this.ip;
>     }
>
>     public void setIp(List ip) {
>         this.ip = ip;
>     }
>
> the html that is generated by struts looks like this (also trimmed for 
> brevity):
>
>   <tr>
>     <td><input type="text" name="ip[0].address" size="30" value=""></td>
>     <td><input type="text" name="ip[0].netmask" size="30" value=""></td>
>   </tr>
>
> the log file contains this output:
>
> bcm@shrike:~/work/cov/src> 12:30:51,850 INFO  [RequestProcessor] 
> Processing a 'POST' for path '/resource/platform/inventory/NewPlatform'
> 12:30:51,851 DEBUG [RequestProcessor]  Storing ActionForm bean instance 
> in scope 'request' under attribute key 'NewPlatformForm'
> 12:30:51,851 DEBUG [RequestProcessor]  Populating bean properties from 
> this request
> 12:30:51,851 DEBUG [BeanUtils] BeanUtils.populate(startTime=now 
> startMonth=null startDay=null startYear=null startHour=00 startMin=00 
> startAmPm=am startTimeZone=PST recurInterval=null 
> recurrenceFrequencyDaily=everyDay numDays=1 numWeeks=1 
> recurrenceDay=[Ljava.lang.Integer;@d11b79 
> recurrenceFrequencyMonthly=onDay numMonths=1 recurrenceWeek=null eachDay=
> null endTime=none endMonth=null endDay=null rid=null type=null name=null 
> location=null description=null  cpuCount=null cpuSpeed=null 
> dhcpServer=null dnsServer=null fqdn=null gateway=null ram=null ip=[], {ok.
> y=[Ljava.lang.String;@62b333, gateway=[Ljava.lang.String;@e2f8c1, 
> ip[0].address=[Ljava.lang.String;@3954b1, 
> ip[0].MACAddress=[Ljava.lang.String;@e746a2, cpuCount=[Ljava.lang.String;
> @ce56f8, dnsServer=[Ljava.lang.String;@afbbe3, 
> description=[Ljava.lang.String;@584e97, resourceType=[Ljava.lang.String;@
> 8fc7ca, ok.x=[Ljava.lang.String;@85bf5f, ram=[Ljava.lang.String;@d733ca, 
> location=[Ljava.lang.String;@891d76, 
> dhcpServer=[Ljava.lang.String;@ed4d06, fqdn=[Ljava.lang.String;@5bece2, 
> name=[Ljava.lang.String;@1cf4e5, cpuSpeed=[Ljava.lang.String;@121e5a, ip[
> 0].netmask=[Ljava.lang.String;@86aad9})
> 12:30:51,851 DEBUG [BeanUtils]   setProperty(startTime=now 
> startMonth=null startDay=null startYear=null startHour=00 startMin=00 
> startAmPm=am startTimeZone=PST recurInterval=null 
> recurrenceFrequencyDaily=everyDay numDays=1 numWeeks=1 
> recurrenceDay=[Ljava.lang.Integer;@d11b79 
> recurrenceFrequencyMonthly=onDay numMonths=1 recurrenceWeek=null eachDay=
> null endTime=none endMonth=null endDay=null rid=null type=null name=null 
> location=null description=null  cpuCount=null cpuSpeed=null 
> dhcpServer=null dnsServer=null fqdn=null gateway=null ram=null ip=[], ok.
> y, [16])
> 12:30:51,852 DEBUG [BeanUtils]     Target bean = false
> 12:30:51,852 DEBUG [BeanUtils]     Target name = y
> 12:30:51,852 DEBUG [BeanUtils]   setProperty(startTime=now 
> startMonth=null startDay=null startYear=null startHour=00 startMin=00 
> startAmPm=am startTimeZone=PST recurInterval=null 
> recurrenceFrequencyDaily=everyDay numDays=1 numWeeks=1 
> recurrenceDay=[Ljava.lang.Integer;@d11b79 
> recurrenceFrequencyMonthly=onDay numMonths=1 recurrenceWeek=null eachDay=
> null endTime=none endMonth=null endDay=null rid=null type=null name=null 
> location=null description=null  cpuCount=null cpuSpeed=null 
> dhcpServer=null dnsServer=null fqdn=null gateway=null ram=null ip=[], 
> gateway, [])
> 12:30:51,852 DEBUG [ConvertUtils] Convert string '' to class 
> 'java.lang.String'
> 12:30:51,852 DEBUG [ConvertUtils]   Using converter 
> org.apache.commons.beanutils.converters.StringConverter@be8216
> 12:30:51,852 DEBUG [BeanUtils]   setProperty(startTime=now 
> startMonth=null startDay=null startYear=null startHour=00 startMin=00 
> startAmPm=am startTimeZone=PST recurInterval=null 
> recurrenceFrequencyDaily=everyDay numDays=1 numWeeks=1 
> recurrenceDay=[Ljava.lang.Integer;@d11b79 
> recurrenceFrequencyMonthly=onDay numMonths=1 recurrenceWeek=null eachDay=
> null endTime=none endMonth=null endDay=null rid=null type=null name=null 
> location=null description=null  cpuCount=null cpuSpeed=null 
> dhcpServer=null dnsServer=null fqdn=null gateway= ram=null ip=[], 
> ip[0].address, [])
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>