{"record":{"id":"f1400473f944f2f9","repo":"SonarSource/sonarqube","slug":"could-not-copy-file","errorCode":null,"errorMessage":"Could not copy file: ","messagePattern":"Could not copy file: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java","lineNumber":212,"sourceCode":"\n    esInstallation.getTrustStorePassword().ifPresent(s -> keyStoreCli.store(TRUSTSTORE_PASSWORD_PROPERTY_KEY, s));\n    esInstallation.getKeyStorePassword().ifPresent(s -> keyStoreCli.store(KEYSTORE_PASSWORD_PROPERTY_KEY, s));\n  }\n\n  private static void setupElasticsearchHttpEncryption(EsInstallation esInstallation, EsKeyStoreCli keyStoreCli) {\n    if (esInstallation.isHttpEncryptionEnabled()) {\n      String esConfPath = esInstallation.getConfDirectory().getAbsolutePath();\n      Path httpKeyStoreLocation = esInstallation.getHttpKeyStoreLocation();\n      copyFile(httpKeyStoreLocation, Paths.get(esConfPath, httpKeyStoreLocation.toFile().getName()));\n      esInstallation.getHttpKeyStorePassword().ifPresent(s -> keyStoreCli.store(HTTP_KEYSTORE_PASSWORD_PROPERTY_KEY, s));\n    }\n  }\n\n  private static void copyFile(Path from, Path to) {\n    try {\n      Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);\n    } catch (IOException e) {\n      throw new IllegalStateException(\"Could not copy file: \" + from, e);\n    }\n  }\n\n  private static void storeElasticsearchLog4j2Properties(EsInstallation esInstallation) {\n    try (FileOutputStream fileOutputStream = new FileOutputStream(esInstallation.getLog4j2PropertiesLocation())) {\n      esInstallation.getLog4j2Properties().store(fileOutputStream, \"log4j2 properties file for ES bundled in SonarQube\");\n    } catch (IOException e) {\n      throw new IllegalStateException(\"Failed to write ES configuration files\", e);\n    }\n  }\n\n  private <T extends JvmOptions> Process launchJava(JavaCommand<T> javaCommand) {\n    ProcessId processId = javaCommand.getProcessId();\n    try {\n      ProcessBuilder processBuilder = create(javaCommand);\n      logLaunchedCommand(javaCommand, processBuilder);\n      return processBuilder.start();\n    } catch (Exception e) {","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java#L194-L230","documentation":"copyFile copies a source file (e.g. ES keystore, HTTP SSL certificate) into the temporary Elasticsearch conf directory with Files.copy(REPLACE_EXISTING). An IOException (source unreadable, target unwritable) is wrapped in this IllegalStateException including the source path, aborting ES setup.","triggerScenarios":"setupElasticsearchAuthentication() or setupElasticsearchHttpEncryption() -> copyFile() when the source file (cert/keystore) cannot be read or the destination in the ES temp conf dir cannot be written.","commonSituations":"Misconfigured sonar.auth.keystore / TLS certificate paths pointing at missing or unreadable files; permission problems in the temp conf dir; certificate file deleted or renamed after configuration.","solutions":["Verify the source file path in the message exists and is readable by the sonarqube user.","Fix permissions on the ES temp conf destination directory.","Re-check sonar.security / HTTPS keystore and certificate configuration properties.","Ensure the source path is a file, not a directory or symlink to a missing target."],"exampleFix":"// before\nsonar.web.https.keyStore=/etc/ssl/certs/nonexistent.p12\n// after\nsonar.web.https.keyStore=/etc/sonarqube/keystore.p12  # verified readable","handlingStrategy":"validation","validationCode":"Path from = Paths.get(keystoreProp);\nif (!Files.isRegularFile(from) || !Files.isReadable(from)) {\n    throw new IllegalStateException(\"Certificate/keystore missing or unreadable: \" + from);\n}","typeGuard":null,"tryCatchPattern":"try { launcher.launch(...); } catch (IllegalStateException e) { if (e.getMessage().startsWith(\"Could not copy file:\")) { verifySourcePath(e); } }","preventionTips":["Verify certificate/keystore paths exist and are readable before startup.","Keep TLS material under a stable, service-readable directory.","Update sonar properties whenever certificates are rotated or moved."],"tags":["filesystem","elasticsearch","file-copy"],"backgroundTag":"file-not-found","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"}