{"record":{"id":"9a9c207f57207874","repo":"SonarSource/sonarqube","slug":"only-a-single-command-line-argument-is-accepted-a","errorCode":null,"errorMessage":"Only a single command-line argument is accepted (absolute path to configuration file)","messagePattern":"Only a single command-line argument is accepted \\(absolute path to configuration file\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/sonar-process/src/main/java/org/sonar/process/ConfigurationUtils.java","lineNumber":40,"sourceCode":"import java.io.File;\nimport java.io.FileInputStream;\nimport java.io.InputStreamReader;\nimport java.io.Reader;\nimport java.nio.charset.StandardCharsets;\nimport java.util.Properties;\nimport org.apache.commons.io.IOUtils;\n\nimport static org.sonar.process.FileUtils2.deleteQuietly;\n\npublic final class ConfigurationUtils {\n\n  private ConfigurationUtils() {\n    // Utility class\n  }\n\n  static Props loadPropsFromCommandLineArgs(String[] args) {\n    if (args.length != 1) {\n      throw new IllegalArgumentException(\"Only a single command-line argument is accepted \" +\n        \"(absolute path to configuration file)\");\n    }\n\n    File propertyFile = new File(args[0]);\n    Properties properties = new Properties();\n    Reader reader = null;\n    try {\n      reader = new InputStreamReader(new FileInputStream(propertyFile), StandardCharsets.UTF_8);\n      properties.load(reader);\n    } catch (Exception e) {\n      throw new IllegalStateException(\"Could not read properties from file: \" + args[0], e);\n    } finally {\n      IOUtils.closeQuietly(reader);\n      deleteQuietly(propertyFile);\n    }\n    return new Props(properties);\n  }\n}","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-process/src/main/java/org/sonar/process/ConfigurationUtils.java#L22-L58","documentation":"ConfigurationUtils.loadPropsFromCommandLineArgs is used by process launchers (search server, web server) that must receive exactly one argument: the absolute path to a generated configuration file. Any other argument count throws this IllegalArgumentException before any file is read.","triggerScenarios":"Launching the process with zero arguments, or with more than one argument (extra flags, quoted paths splitting into two args, manually invoking the main class).","commonSituations":"Hand-crafting java -cp ... org.sonar.process.XxxServer commands; shell quoting causing a path with spaces to become multiple arguments; broken custom launcher scripts.","solutions":["Pass exactly one argument: the absolute path to the generated conf file (e.g. /opt/sonarqube/temp/conf/es.properties)","Quote paths containing spaces: java ... \"$CONFIG_FILE\"","Do not launch these main classes manually; start SonarQube via its standard StartSonar/linux scripts which build the argument","Inspect the launcher script and ensure it expands a single variable, not a list"],"exampleFix":"// before\njava org.sonar.process.Search conf1.properties extra.flag\n// after\njava org.sonar.process.Search /opt/sonarqube/temp/conf/search.properties","handlingStrategy":"validation","validationCode":"if (args.length != 1 || !new File(args[0]).isAbsolute())\n  throw new IllegalArgumentException(\"Expected exactly one arg: absolute path to conf file\");","typeGuard":null,"tryCatchPattern":"try { Props p = ConfigurationUtils.loadPropsFromCommandLineArgs(args); } catch (IllegalArgumentException e) { System.err.println(e.getMessage()); System.exit(64); }","preventionTips":["Start processes via the official SonarQube scripts, not by hand","Always quote \"$CONFIG_PATH\" in launcher scripts","Use absolute paths for the conf file argument","Never pass extra flags to these main classes"],"tags":["process","cli","arguments","configuration"],"backgroundTag":"invalid-cli-argument","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}