Monday, June 8, 2015

java.lang.IllegalArgumentException: Cannot subclass final class class com.sun.proxy.$Proxy52

When you are using Spring Data MongoDB,

you can encounter the following exception:

Caused by: java.lang.IllegalArgumentException: Cannot subclass final class class com.sun.proxy.$Proxy52
at org.springframework.cglib.proxy.Enhancer.generateClass(Enhancer.java:446)
at org.springframework.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33)

It happened by adding `@Repository` accidentally as follows:

@Repository
public interface SomethingRepository extends MongoRepository<Something, String> {
}

Removing `@Repository` fixes the problem.

It would be better to have an exception having better explanation if possible.

Reference:
https://github.com/spring-projects/spring-boot/issues/1929

1 comment:

  1. Thanks. I had the same problem trying out spring data for elasticsearch.

    ReplyDelete