Enhancer.createClass() has thrown an IllegalArgumentException

java.lang.IllegalArgumentException
Javadoc
Thrown to indicate that a method has been passed an illegal or inappropriate argument. @author unascribed @since JDK1.0
at org.springframework.cglib.proxy.Enhancer.generateClass
at org.springframework.cglib.core.DefaultGeneratorStrategy.generate
at org.springframework.cglib.core.AbstractClassGenerator.create
at org.springframework.cglib.proxy.Enhancer.createHelper
at org.springframework.cglib.proxy.Enhancer.createClass
5 frames hidden

Typical Exception Messages

  1. Cannot subclass final class class java.lang.String
  2. Cannot subclass final class class com.sun.proxy.$Proxy14
  3. Cannot subclass final class int
  4. Cannot subclass final class void

Origin

Specific cases

We have seen this error pattern in the following webpages (7)

  1. chrylisvia GitHub1 year ago
    Cannot subclass final class class java.lang.String
  2. Kazuki Shimizuvia Spring JIRA1 year ago
    Cannot subclass final class class java.lang.String
  3. Kazuki Shimizuvia Spring JIRA2 years ago
    Cannot subclass final class class java.lang.String
  4. Unknown authorvia letmeask.co2 years ago
    Error creating bean with name 'contactService' defined in com.stoxa.springjavaconfig.Config.AppConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.stoxa.springjavaconfig.Service.ContactService]: Factory method 'contactService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dao' defined in com.stoxa.springjavaconfig.Config.AppConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.stoxa.springjavaconfig.DAO.ContactDAO]: Factory method 'dao' threw exception; nested exception is java.lang.IllegalArgumentException: Cannot subclass final class class com.sun.proxy.$Proxy14
  5. Unknown authorvia stackoverflow.com2 years ago
    Error creating bean with name 'contactService' defined in com.stoxa.springjavaconfig.Config.AppConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.stoxa.springjavaconfig.Service.ContactService]: Factory method 'contactService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dao' defined in com.stoxa.springjavaconfig.Config.AppConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.stoxa.springjavaconfig.DAO.ContactDAO]: Factory method 'dao' threw exception; nested exception is java.lang.IllegalArgumentException: Cannot subclass final class class com.sun.proxy.$Proxy14
  6. chrylisvia GitHub2 years ago
    Cannot subclass final class class java.lang.String