Failed to load ApplicationContext caused by ArrayIndexOutOfBoundsException in ClassReader

后端 未结 5 1257
無奈伤痛
無奈伤痛 2020-12-06 18:48

When I am running junit test class the below exception arises? How can i resolve this?

Failed to load ApplicationContext
java.lang.IllegalStateException: Fai         


        
相关标签:
5条回答
  • 2020-12-06 19:13

    Try putting the file under src folder. It will be then copied to the WEB-INF/classes folder. Then you can refer to it as classpath:dispatcher-servlet.xml. If the file is not directly under the classes directory, then you cannot use the location as classpath:dispatcher-servlet.xml in your test

    0 讨论(0)
  • 2020-12-06 19:16

    The problem is the location of your xml file. WEB-INF is not part of the classpath. Try copying it under the "src" folder.

    0 讨论(0)
  • 2020-12-06 19:22

    There seems to be some invalid class file on your classpath.

    A blog(http://blog.163.com/mxl_880310/blog/static/1847222162012320102631220/) (in Traditional Chinese) describes a similar problem, the author solves it by checking if there is a zero size class file.

    0 讨论(0)
  • 2020-12-06 19:28

    You have not stated which JDK you are using. If you are using 1.8 then you might find that you will need to upgrade Spring to 4 (or 3.2.9+ as yurez has pointed out).

    See the answer to this question: Java 1.8 ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet

    0 讨论(0)
  • 2020-12-06 19:32

    Most likely you have lambda expression inside one of your spring beans. Apparently, spring 3 beans can't initialize if there is a lambda somewhere in their code. In case migration to spring 4 is not an option, try to rewrite your lambda expressions using anonymous classes, like

    Function<A,B> lambda = new Function() {
        public B apply(A s) { ... }
    }
    

    or move lambda code out of the spring bean. I had the same issue and it helped me, I could still use spring 3 with jre/jdk 8.

    Avoids this failure:

     Caused by: java.lang.ArrayIndexOutOfBoundsException: 10348
        at org.springframework.asm.ClassReader.<init>(Unknown Source)
    
    0 讨论(0)
提交回复
热议问题