Wednesday, February 1, 2017

Issues Debugging Code Using Spring Roo

Seeing delays for data to show up in your variables window when debugging? Seeing java.lang.reflect.InvocationTargetException in the veriables window? These can be caused by the default toString method added by roo when the class is annotated with @RooToString. The default toString method will utilize:
 ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);

If your object has large collections it will iterate through then before returning a result for toString. This can be quite slow. If your has a null value for some fields like version a null pointer exception will be raised which is converted to  the InvocationTargetException you are seeing. To fix these issues you can either add exclude parameters to the RooToString annotation, push in and fix the toString method, or remove the annotation.