Java 1.8 ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet

JavaSpringJava 8

Java Problem Overview


My web application runs fine on JDK 1.7 but crashes on 1.8 with the following exception (during application server startup with Jetty 8). I am using Spring version: 3.2.5.RELEASE.

Exception:

org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet

I assume that problem occurs because of spring and "asm.jar" library on which it depends.

How do I resolve this?

Java Solutions


Solution 1 - Java

As @prunge and @Pablo Lozano stated, you need Spring 4 if you want compile code to Java 8 (--target 1.8), but you can still run apps on Java 8 compiled to Java 7 if you run on Spring 3.2.X.

Check out http://docs.spring.io/spring/docs/current/spring-framework-reference/html/new-in-4.0.html

> Note that the Java 8 bytecode level (-target 1.8, as required by -source 1.8) is only fully supported as of Spring Framework 4.0. In particular, Spring 3.2 based applications need to be compiled with a maximum of Java 7 as the target, even if they happen to be deployed onto a Java 8 runtime. Please upgrade to Spring 4 for Java 8 based applications.

Solution 2 - Java

If you encounter this error even if you compile with -target 1.7, please note that this is because of a bug in Spring Framework which causes ASM classreader to load jdk classes (java.* or javax.*), which are, of course, compiled with -target 1.8.

This, combined with the old ASM version in spring 3.2.8 and below, which does not support parsing of 1.8 class files, can also lead to this error.

More info about the issue can be found here: https://jira.spring.io/browse/SPR-11719

This should be fixed in Spring Framework version 3.2.9, which is due to be released soon.

Of course, upgrading to Spring Framework 4 will also resolve the issue, as it already contains a newer version of ASM.

However, if for some reason you can't upgrade to version 4 yet, it's good to know there's an alternative (soon).

Solution 3 - Java

I had the same problem and solved it. I am using spring 3.x with java 8. If above solutions are not working change the jars and search whether those jars are compatible with the java version you are using or not. spring 3.x is not compatible with java 8.

Solution 4 - Java

Spring 4 can be used for java 8 to resolve this issue. I just tested it and it works. This issue is fixed since Spring 3.2.9-RELEASE version.

Solution 5 - Java

if you use java 8 or next version you need to upgrade spring version and spring version should be 4.xxx

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionstanislav.chetvertkovView Question on Stackoverflow
Solution 1 - JavaLeszek GruchałaView Answer on Stackoverflow
Solution 2 - JavaItayKView Answer on Stackoverflow
Solution 3 - JavarohanView Answer on Stackoverflow
Solution 4 - JavaAdZzZView Answer on Stackoverflow
Solution 5 - JavashafaetjsrView Answer on Stackoverflow