Search code examples
streamsets

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


I am using external javascript inside javascript evaluator in streamsets. But when i try to load the external code i got following error. How should i resolve this. Thanks

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")


Solution

  • As I've responded elsewhere, you will need to add a security policy to be able to load a script file. Add the following to $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";
    };
    

    You will need to restart Data Collector for changes to the security policy file to take effect.