103

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?

3
  • Are you compiling your webapp as Java 8 or Java 7? If 8, it should be possible to compile your classes targeting Java 7 but still run it under Java 8.
    – prunge
    Mar 20, 2014 at 7:59
  • 3
    If you want to target Java8 you'll need Spring 4 Mar 20, 2014 at 8:08
  • It compiles to 1.7 but there is no support for java 8 features. So using jdk 8 in this case doesen't make sence Mar 20, 2014 at 8:15

7 Answers 7

129

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.

5
  • It worked, thanks! For some reason i've missed spring 4 release :-) Mar 20, 2014 at 9:11
  • 2
    This happens to me too, even though the code is still compiled to target 1.7, I only changed the runtime to be java 8. Any ideas?
    – orrsella
    Apr 24, 2014 at 16:24
  • 2
    See ItayK's answer, there is a bug in spring 3.2.8 and below that won't use the right asm version, it's fixed in 3.2.9-
    – chrismarx
    Aug 16, 2016 at 15:30
  • 2
    There was another bug fixed in 3.2.10, so I'd recommend going with 3.2.16 or whatever is the latest. Here are the key Spring bugs that were fixed: Metadata reading should never use ASM for java.* and javax.* types (in particular on JDK 8) Java 8: ASM5 visitors required for parsing INVOKESPECIAL/STATIC on interfaces
    – michaelok
    Oct 26, 2016 at 15:53
  • Thanks ,,it worked by keeping <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.7</source> <target>1.7</target> </configuration> instead of <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> Sep 6, 2017 at 6:24
76

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

4
  • 9
    Upgrading to Spring 3.2.9 helped me.
    – Cengiz
    Apr 9, 2015 at 11:00
  • 2
    This should be the accepted answer because it clearly explains what the issue is
    – Willa
    May 26, 2016 at 11:48
  • 2
    Had this problem with Spring 3.2.5, changed to 3.2.9 and problem solved. Perfect answer. Sep 12, 2016 at 13:29
  • Phew, glad I didn't need to upgrade to Spring 4. Great Answer!
    – rudolfson
    Oct 21, 2016 at 16:31
0

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.

1
  • Basically ... this is what the above answers are saying. So this answer is duplicative.
    – Stephen C
    Dec 31, 2022 at 3:57
0

I had the same problem,

1.Go to:

maven -> executive maven goal -> mvn clean

It helps :)

2.Invalid caches..

1
  • That won't work if you are using the wrong version of Spring.
    – Stephen C
    Dec 31, 2022 at 3:52
0

This problem might because of wrong selection of environments. I tried changing JRE to Java SE 1.8 which is the Java version installed. Project>>Right click>>Properties>>Java Build Path>>Libraries>>Double click JRE system Library>>Execution Environment to JAVA VERSION INSTALLED.

1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jan 9 at 8:52
-1

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

1
-1

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.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.