Home arrow static arrow Java Programming [Archive] - Why do i get this exception?
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Why do i get this exception?
This topic has 6 replies on 1 page.

Posts:80
Registered: 3/10/04
Why do i get this exception?  
Aug 7, 2004 6:59 AM



 
Hi,
i have a CompanyVO class, wich also has members such AddressVO, UserVO. As you can see, i have some other value objects inside CompanyVO.

When i do this:

 CompanyVO companyVO = new CompanyVO();BeanUtils.copyProperties(companyVO, customCompanyVO);

CustomCompanyVO is an object that has only "direct" properties of CompanyVO, stuff like companyName, companyID, companyType (basically all of them are String).

But when i do this.

CompanyVO companyVO = new CompanyVO();BeanUtils.copyProperties(companyVO, customCompanyVO);BeanUtils.copyProperties(companyVO.getAddressVO(), addressVO);

I get the following excetion just on the third line (note the addressVO contain the values to be transfered to AddressVO, wich a VO inside the CompanyVO, as i said).

java.lang.IllegalArgumentException: No destination bean specified
at org.apache.commons.beanutils.BeanUtils.copyProperties(BeanUtils.java:220)
at ltcmelo.session.RegisterCompanyBean.saveCompanyAddressInfo(RegisterCompanyBean.java:157)

So, if i already initialize the companyVO doesn't the addressVO and the userVO memers have to be initialized too ???

This way i'm force to do such thing.

CompanyVO companyVO = new CompanyVO();BeanUtils.copyProperties(companyVO, customCompanyVO);AddressVO auxAddressVO = new AddressVO();BeanUtils.copyProperties(auxAddressVO, addressVO);companyVO.setAddressVO(auxAddressVO);


Is there a better option????

 

Posts:4,906
Registered: 23/07/02
Re: Why do i get this exception?  
Aug 7, 2004 7:10 AM (reply 1 of 6)



 
Where is addressVO defined? I'm guessing it's null.
 

Posts:80
Registered: 3/10/04
Re: Why do i get this exception?  
Aug 7, 2004 10:14 AM (reply 2 of 6)



 
I thought i could initialize addressVO in the following line.
BeanUtils.copyProperties(companyVO.getAddressVO(), addressVO);


Can't I ?
 

Posts:18,384
Registered: 21.03.00
Re: Why do i get this exception?  
Aug 7, 2004 10:22 AM (reply 3 of 6)



 
Nope you wan't.

It must say something like addressVO = something;

/Kaj
 

Posts:18,384
Registered: 21.03.00
Re: Why do i get this exception?  
Aug 7, 2004 10:23 AM (reply 4 of 6)



 
Sorry for typo. wan't = can't

/Kaj
 

Posts:80
Registered: 3/10/04
Re: Why do i get this exception?  
Aug 7, 2004 3:35 PM (reply 5 of 6)



 
No, no, no....

There's a misunderstanting here! Sorry, it's my fault!

addressVO is already initialized and populated with data.

BUT, the addressVO that is a member of companyVO is NOT !!!

Using BeanUtils, i'm trying to populate what's FROM addressVO (wich contains data) TO companyVO.getAddressVO (wich has not been initializes).

So, i thought the i could initialize companyVO.getAddressVO in the way, but as i get the exception, it seems that it's not possible.

My question is WHY is it not possible??? It seems ok to me to copy addressVO to companyVO.getAddressVO in that way.
 

Posts:826
Registered: 7/1/03
Re: Why do i get this exception?  
Aug 7, 2004 3:44 PM (reply 6 of 6)



 
I hate to sound unhelpful in this particular way, but this bean library is an apache-developed one. You may try posting to the jakarta forums if you want a straight answer.
regards,
/k1
 
This topic has 6 replies on 1 page.