I've been tearing apart my problems using copyProperties in an EJB environment;

The scenario is that I am using PropertyUtils.copyProperties to copy everything FROM a simple bean, TO an EJB entity bean.

Earlier tonight I thought that the hangup was over the destination bean, perhaps because it was an EJB remote interface. But my digging turns up that this isn't the case.

The exception is during the getting of the source properties (from my simple bean), and it never even gets to the setting of the destination property.

I extracted a small piece of code from copyProperties and am executing it directly:

// pv is my simple bean, and "name" is a String property within in, which has a getter and a setter method.
PropertyDescriptor descriptor;

// Following two lines are key:
descriptor = PropertyUtils.getPropertyDescriptor(pv, "name");
//descriptor = new PropertyDescriptor("name", pv.getClass());

Method readMethod = descriptor.getReadMethod();
Object value = readMethod.invoke(pv, new Object[0]);


When I use the first of the two "descriptor = " lines (thereby making use of Struts), I get the following exception on the invoke() line:

Name: java.lang.IllegalArgumentException
Message: object is not an instance of declaring class
Stack: java.lang.IllegalArgumentException: object is not an instance of declaring class
at java.lang.reflect.Method.invoke(Native Method)


However, when I use the second of the two "descriptor = " lines (thereby using standard Java SDK reflection), the invoke() line executes correctly.

Any help would be appreciated.

This is using Struts 1.0 beta-1 (binaries).

Regards,
Bryan

Reply via email to