I'm using Spring's <aop:aspectj-autoproxy />
to proxy some JPA repository interfaces.
However, the proxying is failing with the following Cannot subclass final class class $Proxy80
:
Could not generate CGLIB subclass of class [class $Proxy80]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Cannot subclass final class class $Proxy80
As the error, and a quick google, suggests - this occurs when the proxy target is a final class. However, in this chain, there are no classes - only interfaces. Spring generates all the implementations at runtime.
Here's the definition of the interface that's failing:
public interface AuthorDAO extends
CrossStoreJpaRepository<Author,Long>, CrossStoreQueryDslPredicateExecutor<Author> {
}
Note I'm using a custom subclass of spring's JpaRepository and QueryDslPredicateExecutor, defined as follows:
public interface CrossStoreJpaRepository<T, ID extends Serializable> extends JpaRepository<T, ID> {}
public interface CrossStoreQueryDslPredicateExecutor<T> extends QueryDslPredicateExecutor<T>{}
Elsewhere, I define custom aspects for methods on these interfaces:
@Aspect
@Component
public class DocumentLoadingAspect extends AbstractDocumentAspect {
@Around("execution(* com.mangofactory.crossstore.repository.CrossStore*.find*(..))")
public Object loadCrossStoreEntity(ProceedingJoinPoint pjp) throws Throwable
{
// implementation omitted
}
I've confirmed that it's these @Aspect
definitions that are causing the problem by removing them and re-running the app.
What is causing this error? It seems to be that proxying a proxy is failing for some reason.