13

I am trying to integrate Glowroot into my Java application. Unfortunately, I get the following error:

2022-05-13 09:25:57.777 ERROR o.g.a.w.PointcutClassFileTransformer - Unsupported class file major version 61
java.lang.IllegalArgumentException: Unsupported class file major version 61
    at org.glowroot.agent.shaded.org.objectweb.asm.ClassReader.<init>(ClassReader.java:196)

Neither Glowroot nor my application seem to use gradle so I have no idea where this incompatibility is coming from.

Have you got any idea on how I could find the source of the incompatibility and then how I could fix it?

Thank you!

EDIT: I use Glowroot in the version 0.13.6 .

Second edit: Seems like the version of glowroot was the issue...

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
Moritz
  • 307
  • 1
  • 4
  • 10
  • I downloaded file `glowroot-0.13.6-dist.zip` from **glowroot.org** and looked at the class file version for two files. Both were 50 which means they were compiled with Java 1.6 – Abra May 13 '22 at 10:18
  • 1
    @StephenC It's just the bundled ASM from glowroot that doesn't know how to handle that class file version. No info about the JVM version is provided. – Johannes Kuhn May 13 '22 at 10:18
  • Was the problem: ASM was trying to access the Java 17 classes but couldn't. So a newer version of glowroot solved the problem? – matt May 13 '22 at 10:26
  • 1
    @StephenC Given the error originates in `org.glowroot.agent.shaded.org.objectweb.asm.ClassReader` it is more likely that that version of ASM doesn't support class version 61, rather than not running on Java 17. ASM needs to understand the class version to be able to modify its bytecode. – Mark Rotteveel May 13 '22 at 10:26
  • Change the dependency org.springframework spring-context 5.2.9.RELEASE – Manish Halder Aug 24 '23 at 19:23

3 Answers3

26

Also with Jacoco

This error also happens when upgrading to java 17 and having Jacoco 0.8.5. It may complain about some class file that cannot understand.

Just upgrade Jacoco to 0.8.8 or above and you are good to go.

manuelvigarcia
  • 1,696
  • 1
  • 22
  • 32
  • 1
    thanks @manuelvigarcia here i recheck it was a version issue for me. I used 0.8.8 for jacoco https://www.jacoco.org/jacoco/trunk/doc/changes.html – Osman Goni Jan 18 '23 at 22:15
  • Thanks @manuelvigarcia, when migrating the spring-boot project from version 2.7.12 to 3.1.0 I had the same problem with jacoco. By updating the jacoco dependency to this 0.8.8 and the issue was resolved. – Wedson Quintanilha da Silva Jun 12 '23 at 13:07
4

(I incorrectly was zeroing in on the "Unsupported class file major version 61" message without looking at the stacktrace.)

The problem (as pointed out by @Mark Rotteveel) is that glowroot is failing while trying to do some code transformation using ASM. Apparently the ClassReader in the version of ASM that is bundled in glowroot 0.13.6 doesn't understand version 61 (Java 17) class files.

Q: How to solve this?

A: Use glowroot 0.14.0-beta.2 or later; see https://github.com/glowroot/glowroot/issues/906. Alternative, build your application and its dependencies (as required) for an earlier (target) version of Java, and (maybe1) run on an earlier version of Java.


1 - It depends on whether the code transformations involve the ASM ClassReader reading Java SE classes.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
4

The error "unsupported class file major version 61" just means that there's some library that's not supported for Java 17. Read this to understand - https://mkyong.com/java/java-unsupported-class-file-major-version-61/

The stack trace above this error will tell you which dependency is that. You'll need to upgrade that dependency to the Java 17 compliant one.

Sankalp
  • 1,182
  • 2
  • 17
  • 22
  • 1
    This is often what the problem is. But in THIS case, it isn't. See my answer and the question comments. Hint: you need to look *carefully* at the stacktrace! – Stephen C Jan 30 '23 at 03:59
  • QUOTE: "there's some library that's not supported for Java 17" - wrong. You will get this error when you have compiled the class with Java 17(major version 17) and you are trying to run class file under lower java version (version 16 or below). See https://java2blog.com/unsupported-class-file-major-version-61-java/ – Fuad Efendi Jul 18 '23 at 13:00