当前位置: 首页 > news >正文

dolphinscheduler中任务输出变量的问题出现ArrayIndexOutOfBoundsException

一段脚本任务如下:

 ret=`/data/dolphinscheduler/loadOraTable.sh "yonbip/yonbip@10.16.10.69:1521/orcl" "select t.bondcontractno,t.olcunissuemny from yonbip.bond_contract t " "/dmp/biz" "bip" "2025-08-13"`
echo "$ret"
findCols=`echo $ret |grep "new line cols:"`
echo "findCols: findCols"
colsNum=$(echo $findCols | awk -F 'new line cols:{' '{print $2}' | awk -F '}' '{print $1}')echo "#{setValue(newLineColNums=${colsNum})}"
echo "newLineColNums: $colsNum"

运行时出现如下错误:

[INFO] 2025-08-14 05:52:33.633 +0000 - raw script : ret=`/data/dolphinscheduler/loadOraTable.sh "yonbip/yonbip@10.16.10.69:1521/orcl" "select t.bondcontractno,t.olcunissuemny from yonbip.bond_contract t " "/dmp/biz" "bip" "2025-08-13"`
echo "$ret"
findCols=`echo $ret |grep "new line cols:"`
if [ -n $findCols ]
thenecho "findCols: findCols"colsNum=$(echo $findCols | awk -F 'new line cols:{' '{print $2}' | awk -F '}' '{print $1}')
fi
echo "#{setValue(newLineColNums=${colsNum})}"
echo "newLineColNums: $colsNum"
[INFO] 2025-08-14 05:52:33.633 +0000 - task execute path : /tmp/dolphinscheduler/exec/process/hive/18584734972800/18632548623621_8/632/2403
[INFO] 2025-08-14 05:52:33.633 +0000 - Begin to create command file:/tmp/dolphinscheduler/exec/process/hive/18584734972800/18632548623621_8/632/2403/632_2403.command
[INFO] 2025-08-14 05:52:33.633 +0000 - Success create command file, command: #!/bin/bash
BASEDIR=$(cd `dirname $0`; pwd)
cd $BASEDIR
source /opt/datasophon/dolphinscheduler-3.1.8/worker-server/conf/dolphinscheduler_env.sh
/tmp/dolphinscheduler/exec/process/hive/18584734972800/18632548623621_8/632/2403/632_2403_node.sh
[INFO] 2025-08-14 05:52:33.634 +0000 - task run command: sudo -u hive -E bash /tmp/dolphinscheduler/exec/process/hive/18584734972800/18632548623621_8/632/2403/632_2403.command
[INFO] 2025-08-14 05:52:33.635 +0000 - process start, process id is: 74084
[INFO] 2025-08-14 05:52:39.030 +0000 - process has exited. execute path:/tmp/dolphinscheduler/exec/process/hive/18584734972800/18632548623621_8/632/2403, processId:74084 ,exitStatusCode:0 ,processWaitForStatus:true ,processExitValue:0
[ERROR] 2025-08-14 05:52:39.031 +0000 - shell task error
java.lang.ArrayIndexOutOfBoundsException: 1at org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters.getMapByString(AbstractParameters.java:191)at org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters.dealOutParam(AbstractParameters.java:144)at org.apache.dolphinscheduler.plugin.task.shell.ShellTask.handle(ShellTask.java:99)at org.apache.dolphinscheduler.server.worker.runner.DefaultWorkerDelayTaskExecuteRunnable.executeTask(DefaultWorkerDelayTaskExecuteRunnable.java:49)at org.apache.dolphinscheduler.server.worker.runner.WorkerTaskExecuteRunnable.run(WorkerTaskExecuteRunnable.java:174)at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)at java.lang.Thread.run(Thread.java:750)
[ERROR] 2025-08-14 05:52:39.031 +0000 - Task execute failed, due to meet an exception
org.apache.dolphinscheduler.plugin.task.api.TaskException: Execute shell task errorat org.apache.dolphinscheduler.plugin.task.shell.ShellTask.handle(ShellTask.java:108)at org.apache.dolphinscheduler.server.worker.runner.DefaultWorkerDelayTaskExecuteRunnable.executeTask(DefaultWorkerDelayTaskExecuteRunnable.java:49)at org.apache.dolphinscheduler.server.worker.runner.WorkerTaskExecuteRunnable.run(WorkerTaskExecuteRunnable.java:174)at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)at java.lang.Thread.run(Thread.java:750)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1at org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters.getMapByString(AbstractParameters.java:191)at org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters.dealOutParam(AbstractParameters.java:144)at org.apache.dolphinscheduler.plugin.task.shell.ShellTask.handle(ShellTask.java:99)... 9 common frames omitted

脚本本身运行没出现任何错误,但dolphinscheduler提示错误。后来多次研究发现,如果设置变量值为空时会出现这个异常,就是下面这行用于向dolphinscheduler输出变量的脚本:

echo "#{setValue(newLineColNums=${colsNum})}"

如果colsNum为空,就会出现错误。
于是,加一个判断就能解决问题了:

ret=`/data/dolphinscheduler/loadOraTable.sh "${dbConnect}" "select ${slctColums} from ${SRC_DB}.${tableName} t " "/dmp/${DMP_DB}" "${srcSystem}" "${bizDate}"`
colsNum=$(echo $ret |grep "new line cols:" | awk -F 'new line cols:{' '{print $2}' | awk -F '}' '{print $1}')
if (( -n $colsNum ))
thenecho "#{setValue(newLineColNums=${colsNum})}"
fi
echo "newLineColNums: $colsNum"
http://www.lryc.cn/news/621187.html

相关文章:

  • 【记录】Apache SeaTunnel 系统监控信息
  • 反射在Spring IOC容器中的应用——动态创建Bean (补充)
  • Linux 上手 UDP Socket 程序编写(含完整具体demo)
  • 基于SpringBoot+Vue的房屋匹配系统(WebSocket实时通讯、协同过滤算法、地图API、Echarts图形化分析)
  • css中container和media的用法和区别
  • 【Docker】安装kafka案例
  • BGP笔记及实验
  • Windows 11操作系统 Git命令执行速度慢
  • LLM 中 语音编码与文本embeding的本质区别
  • [论文阅读] 人工智能 + 软件工程 | 从模糊到精准:模块化LLM agents(REQINONE)如何重塑SRS生成
  • OpenCV图像处理2:边界填充与平滑滤波实战
  • 数据结构之顺序表相关算法题
  • latex 中破折号的输入
  • 【PCB设计经验】3D模型在线预览!效率便捷!
  • 【浅学】tflite-micro + ESP32S3 + VScode + ESP-IDF 基于例程快速实现自己的图像分类模型训练部署全流程
  • Python学习-----3.基础语法(2)
  • 异步同步,阻塞非阻塞,reactor/proactor
  • spring boot配置es
  • CPP模板编程
  • Redis7学习--持久化机制 RDB与AOF
  • 汽车生产线白皮书:稳联技术Profinet转Ethernet IP网关通信高效性
  • StarRocks优化统计分析
  • Redis入门到实战教程,深度透析redis
  • 零信任架构(Zero Trust Architecture, ZTA)(通过动态验证和最小权限控制,实现对所有访问请求的严格授权和持续监控)
  • Java应用架构实战指南:主流模式解析与Spring落地实践
  • diffusers库学习--pipeline,模型,调度器的基础使用
  • Docker exec进入容器命令的入门教程
  • 使用正则表达式 \s+ 作为分隔符处理字符串
  • 【cmake】编译cpp文件,安装MinGW
  • Python 进阶详解:正则表达式与 JSON —— 文本处理与数据交换的核心技能