{"record":{"id":"7c23f2c7183dfc73","repo":"testcontainers/testcontainers-java","slug":"error-while-executing-init-script-scriptpath","errorCode":null,"errorMessage":"Error while executing init script: ${scriptPath}","messagePattern":"Error while executing init script: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/orientdb/src/main/java/org/testcontainers/containers/OrientDBContainer.java","lineNumber":191,"sourceCode":"        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":173,"sourceCodeEnd":195,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/orientdb/src/main/java/org/testcontainers/containers/OrientDBContainer.java#L173-L195","documentation":"When session.execute(\"sql\", script) throws UnsupportedOperationException (e.g. the OrientDB session/driver refuses the SQL script execution mode), loadScript rethrows it as RuntimeException 'Error while executing init script: <path>' with the original as cause.","triggerScenarios":"Executing an init script whose statements or execution mode aren't supported by the OrientDB session — e.g. non-SQL script content against the 'sql' language, or a driver/DB version that doesn't support script execution.","commonSituations":"Feeding scripts with Gremlin/OrientJS-only commands into the sql executor; using a script written for a newer OrientDB version; init scripts with syntax the embedded server version rejects.","solutions":["Check the cause (UnsupportedOperationException) and make the script statements valid OrientDB SQL","Split the script into statements your OrientDB version supports, or use a JVM driver call per statement","Update the OrientDB container image/version to one matching the script syntax"],"exampleFix":"// before\n// init.sql using unsupported gremlin syntax\nCREATE CLASS Foo EXTENDS V; GREMLIN-style commands...\n// after\nCREATE CLASS Foo EXTENDS V;\nCREATE PROPERTY Foo.name STRING;","handlingStrategy":"try-catch","validationCode":"// pre-validate script contains only supported OrientDB SQL statements before handing it to withInitScript","typeGuard":null,"tryCatchPattern":"try {\n    container.start();\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Error while executing init script\")) {\n        log.error(\"Init script rejected by OrientDB: {}\", scriptPath, e.getCause());\n    }\n    throw e;\n}","preventionTips":["Test init scripts against the same OrientDB version as the container image","Use only OrientDB SQL syntax in scripts (no Gremlin/other languages)","Pin the container image version to match script compatibility"],"tags":["orientdb","testcontainers","init-script","unsupported-operation"],"backgroundTag":"database-query-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"}