In our project, after upgrade the SpringBoot from 3.0.4
to 3.0.9
, several of our tests started to fail on
Caused by: org.springframework.aop.framework.AopConfigException: Unexpected AOP exception
at app//org.springframework.aop.framework.CglibAopProxy.buildProxy(CglibAopProxy.java:222)
at app//org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:158)
at app//org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
at app//org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.buildProxy(AbstractAutoProxyCreator.java:517)
at app//org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:464)
at app//org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:369)
at app//org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:318)
at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:434)
at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1773)
at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598)
... 80 more
Caused by: java.lang.ClassCastException: class our.project.RepositoryConfiguration$LiquibaseConfiguration$$SpringCGLIB$$0 cannot be cast to class org.springframework.cglib.proxy.Factory (our.project.RepositoryConfiguration$LiquibaseConfiguration$$SpringCGLIB$$0 and org.springframework.cglib.proxy.Factory are in unnamed module of loader 'app')
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:91)
at org.springframework.aop.framework.CglibAopProxy.buildProxy(CglibAopProxy.java:213)
... 89 more
It's not bounded just to the our.project.RepositoryConfiguration$LiquibaseConfiguration
. When I disable this configuration, then similar exception occurs on next configuration.
Another weird thing is that the test passes if only the single test class is called or if this class is executed first. Otherwise the ClassCastException ocurs.
We use TestNG for testing.
I tried to upgrade Spring to version 3.0.6 from 3.0.4 and Spring Boot to version 3.0.6 from 3.0.4 and I expect that all our current tests will pass. But for 34 tests of our ~ 2000 there is an exception java.lang.ClassCastException: class our.project.RepositoryConfiguration$LiquibaseConfiguration$$SpringCGLIB$$0 cannot be cast to class org.springframework.cglib.proxy.Factory (our.project.RepositoryConfiguration$LiquibaseConfiguration$$SpringCGLIB$$0 and org.springframework.cglib.proxy.Factory are in unnamed module of loader 'app')
Finally. after almost of week of investigations, I managed to isolate the sinner. Solr 8.2.1 causes this issue. With Solr 8.2.0 it works with Solr 8.2.1 there is class cast exception for spring proxies.
Hard to believe that this is related.