{"record":{"id":"7b355ddb7e007529","repo":"apache/dolphinscheduler","slug":"dms-task-init-error","errorCode":null,"errorMessage":"DMS task init error","messagePattern":"DMS task init error","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-dms/src/main/java/org/apache/dolphinscheduler/plugin/task/dms/DmsTask.java","lineNumber":219,"sourceCode":"     * @return true if stop task when cdc type and cdcStopPosition is not set, else return false\n     */\n    public Boolean isStopTaskWhenCdc() {\n        ReplicationTask replicationTask = dmsHook.describeReplicationTasks();\n        String migrationType = replicationTask.getMigrationType();\n        return migrationType.contains(\"cdc\") && parameters.getCdcStopPosition() == null;\n    }\n\n    /**\n     * init dms hook\n     */\n    public void initDmsHook() throws TaskException {\n        convertJsonParameters();\n\n        dmsHook = new DmsHook();\n        try {\n            BeanUtils.copyProperties(dmsHook, parameters);\n        } catch (Exception e) {\n            throw new TaskException(\"DMS task init error\", e);\n        }\n\n        if (!StringUtils.isNotEmpty(parameters.getStartReplicationTaskType())) {\n            if (parameters.getIsRestartTask()) {\n                dmsHook.setStartReplicationTaskType(DmsHook.START_TYPE.RELOAD_TARGET);\n            } else {\n                dmsHook.setStartReplicationTaskType(DmsHook.START_TYPE.START_REPLICATION);\n            }\n        }\n    }\n\n    /**\n     * convert json parameters to dms parameters\n     */\n    public void convertJsonParameters() throws TaskException {\n        // create a new parameter object using the json data if the json data is not empty\n        if (parameters.getIsJsonFormat() && parameters.getJsonData() != null) {\n            String jsonData = ParameterUtils.convertParameterPlaceholders(parameters.getJsonData(),","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-dms/src/main/java/org/apache/dolphinscheduler/plugin/task/dms/DmsTask.java#L201-L237","documentation":"initDmsHook builds a DmsHook and copies DmsParameters properties onto it with commons-beanutils BeanUtils.copyProperties. If the reflective copy throws (or its nested InvocationTargetException occurs) a TaskException 'DMS task init error' is thrown during task init.","triggerScenarios":"BeanUtils.copyProperties(dmsHook, parameters) throws inside initDmsHook — e.g. a property type mismatch between DmsParameters and DmsHook, an exception thrown by a DmsHook setter, or reflection/NoSuchMethod issues after a version change.","commonSituations":"A new field added to DmsParameters with no compatible setter in DmsHook; incompatible commons-beanutils version on the classpath (plugin classloader is shared); a DmsHook setter validating and rejecting a parameter value.","solutions":["Check the 'Caused by' in the worker log for the real reflection/setter error and fix the offending parameter or DmsHook setter.","Compare DmsParameters fields with DmsHook setters — ensure every copied property has a matching compatible setter.","Pin a compatible commons-beanutils version in the plugin pom.xml to avoid classpath conflicts with other plugins.","If a customjsonData path was used, verify the parsed DmsParameters contain only valid values."],"exampleFix":"// before: DmsHook has no setter for new field -> copyProperties throws\nprivate String newOption; // in DmsParameters, no setter in DmsHook\n// after: add a matching setter in DmsHook\npublic void setNewOption(String newOption) { this.newOption = newOption; }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    init();\n} catch (TaskException e) {\n    log.error(\"DMS init failed\", e.getCause()); // cause holds the BeanUtils reflection error\n}","preventionTips":["Keep DmsParameters fields and DmsHook setters in sync; add a setter for every copied property.","Pin commons-beanutils version in the plugin pom to avoid shared-classloader conflicts.","Make DmsHook setters tolerant (no throwing validation) of copied values.","Run plugin unit tests that call initDmsHook after any field additions."],"tags":["reflection","beanutils","task-init","aws-dms","plugin"],"backgroundTag":"module-init-failed","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}