Unexpected AOP exception; nested exception is java.lang.IllegalStateException: Unable to load cache item

10,401

Solution 1

This seems like https://github.com/eclipse/openj9/issues/5676 which should be fixed in jdk13.

Which specific version of jdk13 are you using (what does 'java -version' say)?

Solution 2

Its version issue in my case, version of spring-core in spring-aop dependency is different to the spring-core dependency I declared, using the same versions fixed the issue

Solution 3

I experienced this issue and in my case, the problem was conflicting versions of spring-core. My service relies on another service and that (core) service has spring-core declared as dependency. When I started using spring-jdbc in my app, it started throwing this exception. The solution was to exclude the spring-core, spring-beans, spring-jcl and spring-tx from spring-jdbc in my pom.xml. I also changed the version of spring-jdbc in my app to be same as spring version in core application (the application on which my app relies).

Solution 4

In my case I had duplicate spring-core dependencies. I removed one and my app started working. I noticed this issue with incompatible version of javaassist dependency also.

Share:
10,401

Related videos on Youtube

Tito
Author by

Tito

Updated on June 04, 2022

Comments

  • Tito
    Tito almost 2 years

    A Spring boot app version 2.1.5.RELEASE has been upgraded to version 2.2.5.RELEASE i.e.

        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.2.5.RELEASE</version>
    <!--    <version>2.1.5.RELEASE</version> -->
        </parent>
    

    Also the background java has been ugraded from version 11 to 13 i.e. "

    openjdk 11 2018-09-25

    openjdk version "13" 2019-09-17

    After the bought upgrades i notice that none of my integrational test ( > 60) were working. I am able to compile the jar file out of my project but non of the test are succesefull. They all show the same exception mentioned below. The interesting thing is that the tests used to work befor the change. I have noticed one more exact question on Stackoveflow i.e. java.lang.VerifyError: Stack map does not match the one at exception handle but it is also left without the answer.

    The only thing that i was able to find on google about similar exception signature were those two pages (The problem is unfortunatlely i can not read chineese) https://gitmemory.com/issue/eclipse/openj9/5676/489772592 and https://blog.csdn.net/Zhao_yanpeng/article/details/102835149

    In the last one the person mention that it is working with openjdk "12.0.1" but i am currenly running version 13 and I still get that exception.

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepositoryImpl' defined in file [Projects/server/target/classes/org/server/Repository/account/user/impl/UserRepositoryImpl.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.IllegalStateException: Unable to load cache item
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:603)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
        ... 121 more
    Caused by: org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.IllegalStateException: Unable to load cache item
        at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:214)
        at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:471)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:350)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:299)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:431)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
        ... 130 more
    Caused by: java.lang.IllegalStateException: Unable to load cache item
        at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:79)
        at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
        at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:134)
        at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:319)
        at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:569)
        at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:416)
        at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:57)
        at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:205)
        ... 137 more
    Caused by: java.lang.VerifyError: Stack map does not match the one at exception handler 9
    Exception Details:
      Location:
        org/server/Repository/account/user/impl/UserRepositoryImpl$$EnhancerBySpringCGLIB$$f765df37.<init>()V @9: athrow
      Reason:
        Current frame's flags are not assignable to stack map frame's.
      Current Frame:
        bci: @0
        flags: { flagThisUninit }
        locals: { uninitializedThis }
        stack: { 'java/lang/RuntimeException' }
      Stackmap Frame:
        bci: @9
        flags: { }
        locals: { }
        stack: { 'java/lang/Throwable' }
      Bytecode:
        0000000: 2a59 b702 8bb8 0192 b1bf bb01 9c5a 5fb7
        0000010: 019f bf                                
      Exception Handler Table:
        bci [0, 9] => handler: 9
        bci [0, 9] => handler: 9
        bci [0, 9] => handler: 10
      Stackmap Table:
        full_frame(@9,{},{Object[#390]})
        same_locals_1_stack_item_frame(@10,Object[#390])
    
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:398)
        at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:571)
        at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:363)
        at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:582)
        at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:110)
        at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:108)
        at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
        ... 144 more
    

    I am using Spring tools Suite Version: 4.5.1.RELEASE Build Id: 202001211336 for Development if that is somehow useful and the jar files are runned on Linux 5.3.0-40-generic kernel.

    Any ideas or hints how to debug that further are really appreciated.

    Update 10.03.2020 : Here is the solution that worked after the Help of Keith and Kriegaex:

    I added the artifacts aspectjrt and aspectjweaver with their corresponding versions 1.9.5. Then I upgaded the versions of the artifacts javassist to 3.26.0-GA and cglib-nodep to 3.3.0 and removed the artifact spring-aop. After that all tests are back in business.

    • Thomas
      Thomas about 4 years
      "The problem is unfortunatlely i can not read chineese" - well, fortunately Chrome is able to translate pages, so the second one states: "Workaround: Comment out the hot deployment dependencies in the pom file" along with an example that removes the dependency to spring boot's dev tools.
    • Tito
      Tito about 4 years
      @Thomas many thanks for the feedback . I already tried removing the spring-boot-devtools artifact which i indeed have in my pom to see if that will help. I recompiled and did "mvn clean compile test-compile" but that did not helped. About the part "hot deployment dependencies" i am not sure i understand that can you elaborate on this a little?
    • Thomas
      Thomas about 4 years
      Unfortunately I can't elaborate on that since I didn't use them myself. The comment indicates that those are part of the dev tools so removing those should already get rid of "hot deployment dependencies".
    • Joachim Sauer
      Joachim Sauer about 4 years
      Just a general hint for the future: If changing two things at once leads to a problem, try changing only one at a time (i.e. upgrade to JDK 13 first, and only if that's working, upgrade the dependency).
    • Tito
      Tito about 4 years
      @JoachimSauer thanks indeed a good advice, i was in a hurry and thought i will try it quick and dirty and now comes the payback :(
    • kriegaex
      kriegaex about 4 years
      If you not just switched the runtime environment but also compiled code with target Java 13, you might run into problems due to a Spring AOP dependency such as CGLIB or Objenesis not understanding Java 13 byte code. But this is just a guess. In the case of AspectJ (not Spring AOP) you definitely would have to upgrade to 1.9.5 which supports Java 13. But your callstack looks more like Spring AOP, AspectJ does not use any dynamic proxies.
    • Tito
      Tito about 4 years
      Kriegaex you put the final nail in the coffin. Here is what i did. I added the artifacts aspectjrt and aspectjweaver with their corresponding versions 1.9.5. Then I upgaded the versions of the artifacts javassist to 3.26.0-GA and cglib-nodep to 3.3.0 and removed the artifact spring-aop. That made it fly again. Please put your answer I will accept bought answers i.e. yours and Keith’s
  • Tito
    Tito about 4 years
    Keith many thanks for this i am currenly running this in a VM that uses openjdk version "13" 2019-09-17 OpenJDK Runtime Environment (build 13+33-Ubuntu-1) OpenJDK 64-Bit Server VM (build 13+33-Ubuntu-1, mixed mode) I will try now to find out if i can install the latest build , since i saw that there is even newer i.e. 13.0.2 directlly from the openJDK site. I will upgrade and let you know if that indeed fixes that problem. Many thanks again.
  • Tito
    Tito about 4 years
    I did removed all my previous JDKs and install the latest i.e. openjdk version "13.0.2" 2020-01-14 OpenJDK Runtime Environment (build 13.0.2+8) . But unfortunately that did not solve the problem. I am still running into the exact same failure. I also mentioned that the stack trace is a little different i.e. in the bug you mentioned the statck trace mentioned caused by "JVMVRFY012" and in my error says "Stack map does not match the one at exception handler 9". I am starting to suspect that this is some different bug. Where do you think i should take this error to?
  • Keith W. Campbell
    Keith W. Campbell about 4 years
    This is from adoptopenjdk.net. It contains the fix for #5676. If you still have the problem with this version, please open an issue at github.com/eclipse/openj9/issues with as much detail as you can provide.
  • Keith W. Campbell
    Keith W. Campbell about 4 years
    I downloaded the Linux x64 version from adoptopenjdk.net; 'java -version' says: jdk13-0.18$ ./jdk-13.0.2+8/bin/java -version openjdk version "13.0.2" 2020-01-14 OpenJDK Runtime Environment AdoptOpenJDK (build 13.0.2+8) Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.18.0, JRE 13 Linux amd64-64-Bit Compressed References 20200117_151 (JIT enabled, AOT enabled) OpenJ9 - 6968c18d7 OMR - 7a1b0239a JCL - 9c5a41bd5f based on jdk-13.0.2+8)