{"record":{"id":"b7b81e0096de83b3","repo":"testcontainers/testcontainers-java","slug":"could-not-load-classpath-init-script-scriptpath","errorCode":null,"errorMessage":"Could not load classpath init script: ${scriptPath}","messagePattern":"Could not load classpath init script: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/orientdb/src/main/java/org/testcontainers/containers/OrientDBContainer.java","lineNumber":188,"sourceCode":"\n    @Deprecated\n    private void loadScript(String path, ODatabaseSession session) {\n        try {\n            URL resource = getClass().getClassLoader().getResource(path);\n\n            if (resource == null) {\n                LOGGER.warn(\"Could not load classpath init script: {}\", scriptPath);\n                throw new RuntimeException(\n                    \"Could not load classpath init script: \" + scriptPath + \". Resource not found.\"\n                );\n            }\n\n            String script = IOUtils.toString(resource, StandardCharsets.UTF_8);\n\n            session.execute(\"sql\", script);\n        } catch (IOException e) {\n            LOGGER.warn(\"Could not load classpath init script: {}\", scriptPath);\n            throw new RuntimeException(\"Could not load classpath init script: \" + scriptPath, e);\n        } catch (UnsupportedOperationException e) {\n            LOGGER.error(\"Error while executing init script: {}\", scriptPath, e);\n            throw new RuntimeException(\"Error while executing init script: \" + scriptPath, e);\n        }\n    }\n}\n","sourceCodeStart":170,"sourceCodeEnd":195,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/orientdb/src/main/java/org/testcontainers/containers/OrientDBContainer.java#L170-L195","documentation":"After resolving the init script resource, loadScript reads it with IOUtils.toString; if that raises IOException (e.g. unreadable/failed stream), it is wrapped in a RuntimeException 'Could not load classpath init script: <path>' with the IOException as cause.","triggerScenarios":"The classpath resource exists but cannot be read into a String — e.g. resource backed by a broken/unreadable source, custom classloader quirks, or I/O errors while opening the URL stream.","commonSituations":"Custom classloader/resource setups in build tools or application servers; resource inside a corrupted jar; very large or special-character scripts causing IO trouble.","solutions":["Inspect the wrapped cause (e.getCause()) for the real IO error and fix the underlying resource access","Ensure the resource is a plain readable file/jar entry on the classpath","Rebuild/repackage so the resource is fresh and accessible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    container.start();\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof IOException) {\n        log.error(\"Failed reading init script {}: {}\", scriptPath, e.getCause().getMessage());\n    }\n    throw e;\n}","preventionTips":["Rebuild jars/resources when scripts change","Avoid unusual classloader setups for test resources","Keep init scripts small, plain UTF-8 files"],"tags":["orientdb","testcontainers","ioexception","init-script"],"backgroundTag":"file-read-failed","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}