SonarSource/sonarqube · error · IllegalStateException
format(CAN_NOT_LOAD_FROM_CLASSPATH, EDITION_FILE_PATH)
Error message
format(CAN_NOT_LOAD_FROM_CLASSPATH, EDITION_FILE_PATH)
What it means
loadEdition reads sonar-edition.txt from the classpath to determine the SonarQube edition. If the resource URL exists but the stream cannot be read (IOException), it throws IllegalStateException with a CAN_NOT_LOAD_FROM_CLASSPATH message naming EDITION_FILE_PATH. It only reaches this path when the resource URL was found but unreadable.
Solutions
- Verify the integrity of the sonar-application jar (re-download / reinstall).
- Check the wrapped IOException cause for the real IO failure.
- Ensure sonar-edition.txt is packaged and readable inside the deployed artifact.
Example fix
// before: reading edition from a corrupted install fails // after: reinstall a clean distribution and confirm the jar contains the resource unzip -l sonar-application.jar | grep sonar-edition.txt
Defensive patterns
Strategy: try-catch
Validate before calling
// Java
URL url = system.getResource("/sonar-edition.txt");
if (url == null) { /* falls back to COMMUNITY upstream */ } Try / catch
// Java
try {
SonarEdition edition = runtime.getEdition();
} catch (IllegalStateException e) {
// log and default to SonarEdition.COMMUNITY or recheck installation integrity
} Prevention
- Verify distribution jar integrity after deployment (checksums).
- Avoid modifying files inside installed jars.
- Monitor disk health on servers hosting the SonarQube installation.
When it happens
Trigger: Calling SonarRuntimeImpl.getEdition() or MetadataLoader.loadEdition(system) when sonar-edition.txt is present on the classpath but its stream fails to open (corrupted jar, IO error reading the packaged resource).
Common situations: Damaged SonarQube installation jar; incomplete deployment where the edition file was partially packaged; file-system I/O errors in the deployment environment.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- format(CAN_NOT_LOAD_FROM_CLASSPATH, filePath)
- Can't read svg template
- Cannot detect path of main jar file
- "Cannot detect path of shutdowner jar file"
- Cannot load from classpath
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/4aa536eca578bcf9.
Report an issue: GitHub.
Appendix: source
Thrown at sonar-plugin-api-impl/src/main/java/org/sonar/api/internal/MetadataLoader.java:95
private static String getParamFromFile(System2 system, String filePath) {
URL url = system.getResource(filePath);
try (Scanner scanner = new Scanner(url.openStream(), StandardCharsets.UTF_8)) {
return scanner.nextLine();
} catch (IOException e) {
throw new IllegalStateException(format(CAN_NOT_LOAD_FROM_CLASSPATH, filePath), e);
}
}
public static SonarEdition loadEdition(System2 system) {
URL url = system.getResource(EDITION_FILE_PATH);
if (url == null) {
return SonarEdition.COMMUNITY;
}
try (Scanner scanner = new Scanner(url.openStream(), StandardCharsets.UTF_8)) {
String editionInFile = scanner.nextLine();
return parseEdition(editionInFile);
} catch (IOException e) {
throw new IllegalStateException(format(CAN_NOT_LOAD_FROM_CLASSPATH, EDITION_FILE_PATH), e);
}
}
static SonarEdition parseEdition(String edition) {
String str = trimToEmpty(edition.toUpperCase(Locale.ENGLISH));
try {
return SonarEdition.valueOf(str);
} catch (IllegalArgumentException e) {
throw new IllegalStateException(format("Invalid edition found in '%s': '%s'", EDITION_FILE_PATH, str));
}
}
}
View on GitHub (pinned to 184c821202)