Link to home
Start Free TrialLog in
Avatar of dkim18
dkim18

asked on

copy pojo bean to struts' action form bean

Hi,

I am trying copy pojo bean to struts' action form bean here.
+++++++++++++++++++

public ActionForward savetest(ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response)throws java.lang.IllegalAccessException,
            java.lang.reflect.InvocationTargetException,  java.lang.NoSuchMethodException {
 
        Demographics demographics = new Demographics();    
        DemographicsDAO demographicsDAO = new DemographicsDAO();
        DemographicsForm demographicsForm =(DemographicsForm) form;  
       
        PropertyUtils.copyProperties( demographics, demographicsForm);
...
+++++++++++
However, I have java.lang.reflect.InvocationTargetException. All properties from both(Demographics and DemographicsForm) are the same. Any idea?

thx,
Avatar of suprapto45
suprapto45
Flag of Singapore image

Hi,

Are you trying to copy all the attributes from Demographics demographics to DemographicsForm demographicsForm?

If so, can you post your PropertyUtils.copyProperties method? I think that this method is created by you, isn't it?

David
Avatar of dkim18
dkim18

ASKER

No, it is from org.apache.commons.beanutils.
ASKER CERTIFIED SOLUTION
Avatar of Mayank S
Mayank S
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dkim18

ASKER

I got this exception.

InvocationTargetException: java.lang.reflect.InvocationTargetException
getTargetException(): java.lang.StackOverflowError
Well that means that there was an infinite recursion. Print the complete stack-trace of the target-exception using printStackTrace ()
Avatar of dkim18

ASKER

Found error and fixed it. I made two getter methods calling each other.
Yes that's indirect recursion.