I'd like to ask about the root cause of the exception:
Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to
java.lang.reflect.ParameterizedType
which happens in Spring when we make Spring generate proxies for classes (i.e. setting proxy-target-class="true"
on a transaction manager):
<tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="true"/>
and when the class to proxy is a parameterized class, i.e.
public class SomeDAOImpl<SomeEntity> implements SomeDAO ...
The full story can be, for example, read in this question: Abstract DAO pattern and Spring's "Proxy cannot be cast to ..." problem!
Question: why can't Spring proxy this class? Is it because it uses old code generation libraries? Because of type erasure? If the SomeDAOImpl
was not a generic class, it would succeed (I checked that).
Please don't answer like: "you should proxy interfaces, not classes". I know that.