wooing

has been compiled by a more recent version of the Java Runtime (class file version 61.0)... 오류 본문

오류일지

has been compiled by a more recent version of the Java Runtime (class file version 61.0)... 오류

우잉_ 2025. 1. 9. 16:01

오류 내용

오류 로그 원문

org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

내용

해당 오류는 SonarQube Server가 실행중인 런타임 버전과 스캐너의 런타임 버전이 맞지 않아 발생한 문제이다. 소나큐브는 런타임 61버전(자바17)을 사용중이고, 프로젝트는 런타임 52버전(자바 8)을 사용중이기때문에 오류가 발생한 것이다.

해당 문제는 자바 8버전의 프로젝트에서 발생하는 문제이고, 유사한 문제로 자바 11의 경우 아래의 메세지와 함께 오류가 발생한다.

this version of the Java Runtime only recognizes class file versions up to 55.0

 

 

SonarQube 버전에 따른 호환 가능한 SonarScanner실행 환경 JDK 버전 목록

SonarQube Server 버전 Sonar Scanner JDK 버전
8.9 • Java 8
• Java 11
9.9 • Java 11
• Java 17
10.4 이상 • Java 17

 

오류 출처:

https://docs.sonarsource.com/sonarqube-server/9.9/requirements/prerequisites-and-overview/

 

Prerequisites and overview

The prerequisities for installing SonarQube.

docs.sonarsource.com

 

해결 방법

Scanner 실행 Java 버전 변경

  1. 프로젝트 sdk버전으로 빌드
  2. 실행 환경 자바17로 버전 변경
    1. jenv혹은 환경변수(zsh, bash) 직접 변경
  3. 변경된 버전에서 ./gradlew sonar 실행

만약 gradle 의존성 문제로 인해 자바17로 sonar를 실행하지 못하는 경우 아래의 Scanner CLI 사용으로 해결할 수 있다.

Scanner CLI 사용

Scanner CLI를 버전에 맞게(Java 17버전 혹은 LTA)실행하여 정적분석을 수행하면 해결할 수 있다.

  1. ./gradlew clean build 명령어로 프로젝트 빌드.
  2. Scanner CLI 실행하여 정적분석 수행

Scanner CLI 실행 튜토리얼 (소나큐브 공식문서)

 

https://docs.sonarsource.com/sonarqube-server/9.9/analyzing-source-code/scanners/sonarscanner/

 

SonarScanner

The SonarScanner is the scanner to use when there is no specific scanner for your build system.

docs.sonarsource.com