java.lang.IllegalStateException: Post-processor tried to replace bean instance of type [com.kratos.domain.profiles.Profile] with (proxy) object of type [com.sun.proxy.$Proxy81] - not supported for aspect-configured classes!

Spring JIRA | Sebastian Dietrich | 2 years ago
  1. 0

    I have domain objects that need to be annotated both as {{@Configurable}} and {{@Validated}}. If I do so, I get an IllegalStateException when instantiating them in tests: {noformat} java.lang.IllegalStateException: Post-processor tried to replace bean instance of type [com.kratos.domain.profiles.Profile] with (proxy) object of type [com.sun.proxy.$Proxy81] - not supported for aspect-configured classes! at org.springframework.beans.factory.wiring.BeanConfigurerSupport.checkExposedObject(BeanConfigurerSupport.java:173) at org.springframework.beans.factory.wiring.BeanConfigurerSupport.configureBean(BeanConfigurerSupport.java:143) at org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect.configureBean(AnnotationBeanConfigurerAspect.aj:63) at org.springframework.beans.factory.aspectj.AbstractDependencyInjectionAspect.ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c(AbstractDependencyInjectionAspect.aj:88) {noformat} IMHO this is a typical need for DDD entities (they often have @Autowired references to e.g. repositories --> thus @Configurable - and they often need method-level validation for their business-functionality --> thus @Validated) .

    Spring JIRA | 2 years ago | Sebastian Dietrich
    java.lang.IllegalStateException: Post-processor tried to replace bean instance of type [com.kratos.domain.profiles.Profile] with (proxy) object of type [com.sun.proxy.$Proxy81] - not supported for aspect-configured classes!
  2. 0

    I have domain objects that need to be annotated both as {{@Configurable}} and {{@Validated}}. If I do so, I get an IllegalStateException when instantiating them in tests: {noformat} java.lang.IllegalStateException: Post-processor tried to replace bean instance of type [com.kratos.domain.profiles.Profile] with (proxy) object of type [com.sun.proxy.$Proxy81] - not supported for aspect-configured classes! at org.springframework.beans.factory.wiring.BeanConfigurerSupport.checkExposedObject(BeanConfigurerSupport.java:173) at org.springframework.beans.factory.wiring.BeanConfigurerSupport.configureBean(BeanConfigurerSupport.java:143) at org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect.configureBean(AnnotationBeanConfigurerAspect.aj:63) at org.springframework.beans.factory.aspectj.AbstractDependencyInjectionAspect.ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c(AbstractDependencyInjectionAspect.aj:88) {noformat} IMHO this is a typical need for DDD entities (they often have @Autowired references to e.g. repositories --> thus @Configurable - and they often need method-level validation for their business-functionality --> thus @Validated) .

    Spring JIRA | 2 years ago | Sebastian Dietrich
    java.lang.IllegalStateException: Post-processor tried to replace bean instance of type [com.kratos.domain.profiles.Profile] with (proxy) object of type [com.sun.proxy.$Proxy81] - not supported for aspect-configured classes!
  3. 0

    Lazy Loading using Spring Data Neo4j 4 + AspectJ LTW running on Tomcat

    Stack Overflow | 6 months ago | Guilherme
    java.lang.IllegalStateException: Post-processor tried to replace bean instance of type [com.test.server.graph.domain.model.Sequence] with (proxy) object of type [org.springframework.beans.factory.aspectj.$Proxy96] - not supported for aspect-configured classes!
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Using Spring's Cachable annotation on methods that returns Hibernate objects

    Stack Overflow | 1 year ago | Jan Vladimir Mostert
    java.lang.IllegalStateException: Post-processor tried to replace bean instance of type [com.ahp.core.model.Session] with (proxy) object of type [com.sun.proxy.$Proxy66] - not supported for aspect-configured classes!
  6. 0

    IllegalStateException when creating EntityManagerFactory Bean

    Stack Overflow | 1 month ago | user856354
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactoryBean' defined in com.global.us.app.config.PersistenceConfig: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'annotationDrivenTransactionManager' defined in com.global.us.app.config.PersistenceConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.PlatformTransactionManager]: Factory method 'annotationDrivenTransactionManager' threw exception; nested exception is java.lang.IllegalStateException: @Bean method PersistenceConfig.configureEntityManagerFactory called as a bean reference for type [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] but overridden by non-compatible bean instance of type [com.sun.proxy.$Proxy30]. Overriding bean of same name declared in: com.global.us.app.config.PersistenceConfig

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Post-processor tried to replace bean instance of type [com.kratos.domain.profiles.Profile] with (proxy) object of type [com.sun.proxy.$Proxy81] - not supported for aspect-configured classes!

      at org.springframework.beans.factory.wiring.BeanConfigurerSupport.checkExposedObject()
    2. Spring Beans
      BeanConfigurerSupport.configureBean
      1. org.springframework.beans.factory.wiring.BeanConfigurerSupport.checkExposedObject(BeanConfigurerSupport.java:173)
      2. org.springframework.beans.factory.wiring.BeanConfigurerSupport.configureBean(BeanConfigurerSupport.java:143)
      2 frames
    3. Spring Aspects
      AbstractDependencyInjectionAspect.ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c
      1. org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect.configureBean(AnnotationBeanConfigurerAspect.aj:63)
      2. org.springframework.beans.factory.aspectj.AbstractDependencyInjectionAspect.ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c(AbstractDependencyInjectionAspect.aj:88)
      2 frames