无法将外部 js 脚本添加到流集中的 javascript 评估器

can't add external js script to javascript Evaluator in streamsets

我在流集中使用 javascript 内的外部 javascript 求值器。但是当我尝试加载外部代码时出现以下错误。我应该如何解决这个问题。谢谢

ERROR SafeScheduledExecutorService - Uncaught throwable from com.streamsets.pipeline.lib.executor.SafeScheduledExecutorService$SafeCallable@69717812: com.streamsets.datacollector.util.PipelineException: PREVIEW_0003 - Encountered error while previewing : java.security.AccessControlException: access denied ("java.io.FilePermission" "/opt/streamsets-datacollector-user-libs/test.js" "read") com.streamsets.datacollector.util.PipelineException: PREVIEW_0003 - Encountered error while previewing : java.security.AccessControlException: access denied ("java.io.FilePermission" "/opt/streamsets-datacollector-user-libs/test.js" "read")

正如我的回复 elsewhere,您需要添加安全策略才能加载脚本文件。将以下内容添加到 $SDC_CONF/sdc-security.policy :

// Set global perm so that JS can load scripts from this directory
// Note - this means any code in the JVM can read this dir!
grant {
  permission java.io.FilePermission "/opt/streamsets-datacollector-user-libs/-", "read";
};

您需要重新启动 Data Collector 才能使对安全策略文件的更改生效。