1

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

Tamizharasan
  • 293
  • 1
  • 5
  • 18

1 Answers1

1

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.

metadaddy
  • 4,234
  • 1
  • 22
  • 46
  • By default policy file have the following line `// custom stage library directory grant codebase "file:///opt/streamsets-datacollector-user-libs/-" { permission java.security.AllPermission; };` That means if I add the required file inside that directory. Should the file load in my js evaluator processor without reloading ?? – Tamizharasan Jul 24 '18 at 06:24
  • That's a different permission - that is saying that code loaded from `/opt/streamsets-datacollector-user-libs` can do anything. This is different from the permission I described, which says that any code can load files from `/opt/streamsets-datacollector-user-libs`. – metadaddy Jul 24 '18 at 17:41
  • Thanks for the clarification – Tamizharasan Jul 24 '18 at 17:45
  • Use this code block if you want to use HTTP call inside your javascript evaluator. [https://gist.github.com/billybong/a462152889b6616deb02](https://gist.github.com/billybong/a462152889b6616deb02) – Tamizharasan Jul 25 '18 at 07:29