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 | 7 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

    Injecting non-Spring beans & Spring AOP not work together?

    Coderanch | 8 years ago | Eric Xin Zhang
    java.lang.IllegalStateException: Post-processor tried to replace bean instance of type [com.springinaction.springidol.Magician] with (proxy) object of type [$Proxy5] - not supported for aspect-configured classes!

    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