-1

I have two classes with the same attributes and the same get and set methods, one follows the DTO pattern and a VO pattern.

So I have something like this:

classDTO
    private String x;
    private String y;

classVO
    private String x;
    private String y;

Why is the following code throwing the exception illegalArgumentException?

BeanUtils.copyProperties(classVO, classDTO);
David Ferenczy Rogožan
  • 23,966
  • 9
  • 79
  • 68
resla95
  • 1,017
  • 2
  • 11
  • 18

1 Answers1

0

Read the API and you get the answer to your question:

https://commons.apache.org/proper/commons-beanutils/javadocs/v1.9.3/apidocs/org/apache/commons/beanutils/BeanUtils.html

Throws:

IllegalArgumentException - if the dest or orig argument is null or if the dest property type is different from the source type and the relevant converter has not been registered.

Also, the Java definition of a bean is a serializable class with a default constructor and getters and setters that allow access to its fields. Your example classes don't fulfill those requirements.

Crusha K. Rool
  • 1,502
  • 15
  • 24