[
https://issues.apache.org/jira/browse/NIFI-9944?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17527546#comment-17527546
]
Armin Aschoff edited comment on NIFI-9944 at 4/25/22 2:47 PM:
--------------------------------------------------------------
Hey [~mattyb149] - thanks for looking at this (and BTW all your many posts &
blogs I've learned so much from!!)
Unfortunately this is _not_ a dupe of the copy/paste issue. The failure I get
is evident after following the workaround noted in that issue.
Also, affects the script when it is a script file.
The issue here is that I cannot access the classes of the included module (if I
remove the attempt to access StringEscapeUtils but leaving the module reference
in place then the script runs fine).
was (Author: JIRAUSER285365):
Hey [~mattyb149] - thanks for looking at this (and BTW all your many posts &
blogs I've learned so much from!!)
Unfortunately this is _not_ a dupe of the copy/paste issue. The failure I get
is evident after following the workaround noted in that issue.
Also, affects the script when it is a script file.
> InvokeScriptedProcessor not seeing classes in imported Modules
> --------------------------------------------------------------
>
> Key: NIFI-9944
> URL: https://issues.apache.org/jira/browse/NIFI-9944
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Affects Versions: 1.15.3
> Environment: Linux / GCP
> Reporter: Armin Aschoff
> Priority: Critical
> Fix For: 1.17.0, 1.16.1
>
>
> Create a new InvokeScriptedProcessor.
> Set Module Directory: ./scripts/jars/commons-text-1.6/
> - have tried setting absolute & relative paths, paths to directories, paths
> to jar files, different versions of commons-text, trailing slash/no trailing
> slash, etc. No differences
> Set script engine ECMAScript
> Write js script that tries to call a static method in commons-text. Script
> can be either script file or script body, no difference
> Always get ClassNotFoundException error:
> {noformat}
> Component is invalid: 'ScriptValidation' validated against
> './scripts/testCsv.js' is invalid because Unable to load script due to
> java.lang.ClassNotFoundException:
> org.apache.commons.text.StringEscapeUtils{noformat}
>
> Have tried Java.type and Packages. to try to access the class.
> Any/all help much appreciated as rapidly losing remaining hair!
> Sample script:
> {code:java}
> // base interface & class stuff
> var Processor = Java.type("org.apache.nifi.processor.Processor")
> var Relationship = Java.type("org.apache.nifi.processor.Relationship")
> var HashSet = Java.type("java.util.HashSet")
> var log = null
> // stuff to read/write flowfile content
> var InputStreamCallback =
> Java.type("org.apache.nifi.processor.io.InputStreamCallback")
> var OutputStreamCallback =
> Java.type("org.apache.nifi.processor.io.OutputStreamCallback")
> var IOUtils = Java.type("org.apache.commons.io.IOUtils")
> var StandardCharsets = Java.type("java.nio.charset.StandardCharsets")
> var StringEscapeUtils = Java.type("org.apache.commons.text.StringEscapeUtils")
> function getPropertyDescriptors() { return []}
> // =========== Define output relationships ================
> var REL_SUCCESS = new
> Relationship.Builder().name("success").description("FlowFiles that were
> successfully processed are routed here").build()
> function getRelationships() {
> var r = new HashSet()
> r.add(REL_SUCCESS)
> return r
> }
> //=======================================
> // Execute the main script when triggered
> function onTrigger(context, sessionFactory) {
> var session = sessionFactory.createSession()
> var flowFile = session.get()
> if (flowFile !== null) {
> var test = "boo"
> test = StringEscapeUtils.escapeCsv("foo")
> log.warn(test)
> session.transfer(flowFile, REL_SUCCESS)
> }
> session.commit()
> }
> // ======================================================
> // Other functions required to satisfy interface contract
> function initialize(context) {log = context.logger}
> function validate(context) {return null}
> function getPropertyDescriptor(name) {return
> getPropertyDescriptors().find(function (property) {
> return property.getName().equalsIgnoreCase(name)
> })}
> function onPropertyModified(descriptor, oldValue, newValue) {return null}
> function getIdentifier() {return null}
> processor = this
> {code}
--
This message was sent by Atlassian Jira
(v8.20.7#820007)