About java.lang.reflect.InvocationTargetException, usually use the Clone tool method to the Copy object, today suddenly jumped out of this anomaly, at first glance also think is the field matching problem, a look is not, and then compare the definition of object, found that there is a custom object The constructive method of the argument, not the non-parametric construction method Plus, see this estimate should be caused by this, because the cloning of the time to create a new object, but found that there is no parameter construction method, so there is the above error, and then add the non-parametric construction method to try again, done.
General non-parametric construction method does not add also nothing, but still add good, this is still coding habits of the problem.
Public Static<t, e> E Clone (T source, class<e>ClassType) { if(Source = =NULL) { return NULL; } E TargetInstance=NULL; Try{TargetInstance=classtype.newinstance (); } Catch(instantiationexception e) {Throw NewRuntimeException (e); } Catch(illegalaccessexception e) {Throw NewRuntimeException (e); } beanutils.copyproperties (source, targetinstance); returnTargetInstance; }
Java.lang.reflect.InvocationTargetException