commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tripurari.Sha...@VerizonWireless.com
Subject RE: BeanUtils problem
Date Tue, 18 Jul 2006 13:24:35 GMT

oh thanks for reminding me thank you !!! 


-----Original Message-----
From: will pugh [mailto:willpugh@sourcelabs.com]
Sent: Friday, July 14, 2006 7:29 PM
To: Jakarta Commons Users List
Subject: Re: BeanUtils problem


I believe the problem here may be that class Zoo and class Pojo are not 
declared public.

When BeanUtils tries to find an setter that is accessible to it, it 
needs to check for a public method as well as a public class.

    --Will

Tripurari.Sharma@VerizonWireless.com wrote:

>i have two beans:
>
>1: 
>class Zoo {
>	
>	private String firstName = "Zoo1";
>
>	public String getFirstName() {
>		return firstName;
>	}
>	public void setFirstName(String firstName) {
>		this.firstName = firstName;
>	}
>}
>
>2: 
>
>class Pojo {
>	
>	private String firstName = "Pojo1";
>
>	public String getFirstName() {
>		return firstName;
>	}
>	public void setFirstName(String firstName) {
>		this.firstName = firstName;
>	}
>}
>
>and engine class is:
>
>import org.apache.commons.beanutils.BeanUtils;
>
>public class ZipcodeLookup {
>	
>	public static void main(String[] args){
>		
>		Pojo p = new Pojo();
>		Zoo z = new Zoo();
>		try {
>			BeanUtils.copyProperties(z, p);
>			String ss = new String("ssss");
>			BeanUtils.setProperty(z, "firstName", ss);
>		} catch (Exception e) {
>			System.out.println("ex... "+e.toString());
>		}
>
>		System.out.println("Zip: "+z.getFirstName());
>		System.out.println("Pojo: "+p.getFirstName());
>
>	}
>	
> }
>
>when it executes this line:
>BeanUtils.copyProperties(z, p);
>it does noting, its not copying the properties to z,
>
>and when it executes this line
>
>String ss = new String("ssss");
>BeanUtils.setProperty(z, "firstName", ss);
>
>it dies by saying java.lang.reflect.InvocationTargetException: Cannot set firstName
>
>see log: 
>[20060714 17:46:23] DEBUG BeanUtils : BeanUtils.copyProperties(Zoo@116ab4e, Pojo@148aa23)
>[20060714 17:46:23] DEBUG BeanUtils :   setProperty(Zoo@116ab4e, firstName, ssss)
>[20060714 17:46:23] DEBUG ConvertUtils : Convert string 'ssss' to class 'java.lang.String'
>[20060714 17:46:23] DEBUG ConvertUtils :   Using converter org.apache.commons.beanutils.converters.StringConverter@bb7465
>ex... java.lang.reflect.InvocationTargetException: Cannot set firstName
>Zip: Zoo1
>Pojo: Pojo1
>
>what is the problem, i try injecting data using reflection that works, why its not?
>
>
>
>The information contained in this message and any attachment may be
>proprietary, confidential, and privileged or subject to the work
>product doctrine and thus protected from disclosure.  If the reader
>of this message is not the intended recipient, or an employee or
>agent responsible for delivering this message to the intended
>recipient, you are hereby notified that any dissemination,
>distribution or copying of this communication is strictly prohibited.
>If you have received this communication in error, please notify me
>immediately by replying to this message and deleting it and all
>copies and backups thereof.  Thank you.
>
>
>  
>

---------------------------------------------------------------------
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


Mime
View raw message