合 dataX中json文件报错java.lang.String cannot be cast to java.util.List
现象
在使用datax将OB中的数据导出到csv文件时,出现了一个没有见过的错误:java.lang.String cannot be cast to java.util.List
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | [admin@0209306f10bf tmp]$ python2 /usr/local/datax/bin/datax.py /usr/local/datax/job/oceanbase2csv.json DataX (DATAX-OPENSOURCE-3.0), From Alibaba ! Copyright (C) 2010-2017, Alibaba Group. All Rights Reserved. 2022-01-10 09:47:22.759 [main] INFO VMInfo - VMInfo# operatingSystem class => sun.management.OperatingSystemImpl 2022-01-10 09:47:22.770 [main] INFO Engine - the machine info => osInfo: Red Hat, Inc. 1.8 25.312-b07 jvmInfo: Linux amd64 3.10.0-1127.10.1.el7.x86_64 cpu num: 16 totalPhysicalMemory: -0.00G freePhysicalMemory: -0.00G maxFileDescriptorCount: -1 currentOpenFileDescriptorCount: -1 GC Names [PS MarkSweep, PS Scavenge] MEMORY_NAME | allocation_size | init_size PS Eden Space | 256.00MB | 256.00MB Code Cache | 240.00MB | 2.44MB Compressed Class Space | 1,024.00MB | 0.00MB PS Survivor Space | 42.50MB | 42.50MB PS Old Gen | 683.00MB | 683.00MB Metaspace | -0.00MB | 0.00MB 2022-01-10 09:47:22.806 [main] INFO Engine - { "content":[ { "reader":{ "name":"oceanbasev10reader", "parameter":{ "column":[ "id" ], "connection":[ { "jdbcUrl":"||_dsc_ob10_dsc_||obce-single:obmysql||_dsc_ob10_dsc_||jdbc:oceanbase://127.0.0.1:2883/sbtest?useUnicode=true&characterEncoding=utf-8", "table":[ "sbtest1" ] } ], "password":"***", "username":"root", "where":"id <=10" } }, "writer":{ "name":"txtfilewriter", "parameter":{ "dateFormat":"yyyy-MM-dd hh:mm:ss", "fieldDelimiter":",", "fileName":"ob2csv", "path":"/tmp", "writeMode":"truncate" } } } ], "setting":{ "errorLimit":{ "percentage":0.1, "record":0 }, "speed":{ "channel":4 } } } 2022-01-10 09:47:22.841 [main] WARN Engine - prioriy set to 0, because NumberFormatException, the value is: null 2022-01-10 09:47:22.845 [main] INFO PerfTrace - PerfTrace traceId=job_-1, isEnable=false, priority=0 2022-01-10 09:47:22.845 [main] INFO JobContainer - DataX jobContainer starts job. 2022-01-10 09:47:22.848 [main] INFO JobContainer - Set jobId = 0 2022-01-10 09:47:22.880 [job-0] ERROR JobContainer - Exception when job run java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at com.alibaba.datax.common.util.Configuration.getList(Configuration.java:426) ~[datax-common-0.0.1-SNAPSHOT.jar:na] at com.alibaba.datax.plugin.reader.oceanbasev10reader.OceanBaseReader$Job.setDatabaseType(OceanBaseReader.java:71) ~[oceanbasev10reader-0.0.1-SNAPSHOT.jar:na] at com.alibaba.datax.plugin.reader.oceanbasev10reader.OceanBaseReader$Job.init(OceanBaseReader.java:38) ~[oceanbasev10reader-0.0.1-SNAPSHOT.jar:na] at com.alibaba.datax.core.job.JobContainer.initJobReader(JobContainer.java:673) ~[datax-core-0.0.1-SNAPSHOT.jar:na] at com.alibaba.datax.core.job.JobContainer.init(JobContainer.java:303) ~[datax-core-0.0.1-SNAPSHOT.jar:na] at com.alibaba.datax.core.job.JobContainer.start(JobContainer.java:113) ~[datax-core-0.0.1-SNAPSHOT.jar:na] at com.alibaba.datax.core.Engine.start(Engine.java:92) [datax-core-0.0.1-SNAPSHOT.jar:na] at com.alibaba.datax.core.Engine.entry(Engine.java:171) [datax-core-0.0.1-SNAPSHOT.jar:na] at com.alibaba.datax.core.Engine.main(Engine.java:204) [datax-core-0.0.1-SNAPSHOT.jar:na] 2022-01-10 09:47:22.890 [job-0] INFO StandAloneJobContainerCommunicator - Total 0 records, 0 bytes | Speed 0B/s, 0 records/s | Error 0 records, 0 bytes | All Task WaitWriterTime 0.000s | All Task WaitReaderTime 0.000s | Percentage 0.00% 2022-01-10 09:47:22.894 [job-0] ERROR Engine - 经DataX智能分析,该任务最可能的错误原因是: com.alibaba.datax.common.exception.DataXException: Code:[Framework-02], Description:[DataX引擎运行过程出错,具体原因请参看DataX运行结束时的错误诊断信息 .]. - java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at com.alibaba.datax.common.util.Configuration.getList(Configuration.java:426) at com.alibaba.datax.plugin.reader.oceanbasev10reader.OceanBaseReader$Job.setDatabaseType(OceanBaseReader.java:71) at com.alibaba.datax.plugin.reader.oceanbasev10reader.OceanBaseReader$Job.init(OceanBaseReader.java:38) at com.alibaba.datax.core.job.JobContainer.initJobReader(JobContainer.java:673) at com.alibaba.datax.core.job.JobContainer.init(JobContainer.java:303) at com.alibaba.datax.core.job.JobContainer.start(JobContainer.java:113) at com.alibaba.datax.core.Engine.start(Engine.java:92) at com.alibaba.datax.core.Engine.entry(Engine.java:171) at com.alibaba.datax.core.Engine.main(Engine.java:204) - java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at com.alibaba.datax.common.util.Configuration.getList(Configuration.java:426) at com.alibaba.datax.plugin.reader.oceanbasev10reader.OceanBaseReader$Job.setDatabaseType(OceanBaseReader.java:71) at com.alibaba.datax.plugin.reader.oceanbasev10reader.OceanBaseReader$Job.init(OceanBaseReader.java:38) at com.alibaba.datax.core.job.JobContainer.initJobReader(JobContainer.java:673) at com.alibaba.datax.core.job.JobContainer.init(JobContainer.java:303) at com.alibaba.datax.core.job.JobContainer.start(JobContainer.java:113) at com.alibaba.datax.core.Engine.start(Engine.java:92) at com.alibaba.datax.core.Engine.entry(Engine.java:171) at com.alibaba.datax.core.Engine.main(Engine.java:204) at com.alibaba.datax.common.exception.DataXException.asDataXException(DataXException.java:40) at com.alibaba.datax.core.job.JobContainer.start(JobContainer.java:162) at com.alibaba.datax.core.Engine.start(Engine.java:92) at com.alibaba.datax.core.Engine.entry(Engine.java:171) at com.alibaba.datax.core.Engine.main(Engine.java:204) Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at com.alibaba.datax.common.util.Configuration.getList(Configuration.java:426) at com.alibaba.datax.plugin.reader.oceanbasev10reader.OceanBaseReader$Job.setDatabaseType(OceanBaseReader.java:71) at com.alibaba.datax.plugin.reader.oceanbasev10reader.OceanBaseReader$Job.init(OceanBaseReader.java:38) at com.alibaba.datax.core.job.JobContainer.initJobReader(JobContainer.java:673) at com.alibaba.datax.core.job.JobContainer.init(JobContainer.java:303) at com.alibaba.datax.core.job.JobContainer.start(JobContainer.java:113) ... 3 more |
分析
原因:在dataX部分reader读取部分的jdbc的值需要使用“[]”括起来,是jdbc固定的模板。
运行命令查看模板:python2 /usr/local/datax/bin/datax.py -r mysqlreader -w mysqlwriter
得到结果: