I did the same thing on a project.  I had one method
to set and get a plain JavaBean.  I did use reflection
once I was inside the container managed EJB to
populate the values from the JavaBean to the EJB.

David

--- "Deadman, Hal" <[EMAIL PROTECTED]> wrote:
> Although copyProperties to an entity bean might
> work, it would be making a
> call through the remote interface each time it sets
> a property on the entity
> bean. I think it's good practice to minimize the
> number of remote calls made
> to an EJB. (Often in practice the calls are not
> really remote but it's good
> to pretend like they could be.) That would allow you
> to separate your JSPs
> and EJBs or use Tomcat for JSPs and Weblogic for
> EJBs. Normally instead of
> calling set methods on an entity bean from the web
> tier, I call a session
> bean and pass a simple JavaBean to it that isn't
> tied to Struts, often the
> bean may have been nested in an ActionForm. Then I
> have a create or an
> update method in the entity bean that accepts the
> JavaBean as an argument. I
> don't always put all the getters and setters for
> individual fields in the
> entity bean remote interface unless I need them. 
>  
> Sorry if this isn't helpful, I would be interested
> to hear if anyone
> disagrees. 
>  
> Hal
>  
>  -----Original Message-----
> From: Bryan Field-Elliot
> [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 13, 2001 12:06 AM
> To: [EMAIL PROTECTED]
> Subject: More on my copyProperties/EJB woes
> 
> 
> 
> 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
> 
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/

Reply via email to