添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
I am getting following error in NiFi `ExecuteScript` processor.
```java
18:07:09 UTCERROR9e1d9c5e-0188-1000-ffff-fffffbc25817
10.42.62.250:8080ExecuteScript[id=9e1d9c5e-0188-1000-ffff-fffffbc25817] ExecuteScript[id=9e1d9c5e-0188-1000-ffff-fffffbc25817] failed to process due to org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: java.lang.IllegalStateException: java.lang.IllegalStateException: StandardFlowFileRecord[uuid=40d42213-2c7a-49a2-8c5d-5a7fc58bad2d,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1686706804350-73290, container=default, section=586], offset=6556, length=39642],offset=0,name=40d42213-2c7a-49a2-8c5d-5a7fc58bad2d,size=39642] already in use for an active callback or an InputStream created by ProcessSession.read(FlowFile) has not been closed in <script> at line number 37
- Caused by: javax.script.ScriptException: java.lang.IllegalStateException: java.lang.IllegalStateException: StandardFlowFileRecord[uuid=40d42213-2c7a-49a2-8c5d-5a7fc58bad2d,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1686706804350-73290, container=default, section=586], offset=6556, length=39642],offset=0,name=40d42213-2c7a-49a2-8c5d-5a7fc58bad2d,size=39642] already in use for an active callback or an InputStream created by ProcessSession.read(FlowFile) has not been closed in <script> at line number 37
- Caused by: Traceback (most recent call last):
File "<script>", line 37, in <module>
at org.apache.nifi.controller.repository.StandardProcessSession.validateRecordState(StandardProcessSession.java:3715)
at org.apache.nifi.controller.repository.StandardProcessSession.validateRecordState(StandardProcessSession.java:3710)
at org.apache.nifi.controller.repository.StandardProcessSession.transfer(StandardProcessSession.java:2349)
at jdk.internal.reflect.GeneratedMethodAccessor2736.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.IllegalStateException: java.lang.IllegalStateException: StandardFlowFileRecord[uuid=40d42213-2c7a-49a2-8c5d-5a7fc58bad2d,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1686706804350-73290, container=default, section=586], offset=6556, length=39642],offset=0,name=40d42213-2c7a-49a2-8c5d-5a7fc58bad2d,size=39642] already in use for an active callback or an InputStream created by ProcessSession.read(FlowFile) has not been closed
- Caused by: java.lang.IllegalStateException: StandardFlowFileRecord[uuid=40d42213-2c7a-49a2-8c5d-5a7fc58bad2d,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1686706804350-73290, container=default, section=586], offset=6556, length=39642],offset=0,name=40d42213-2c7a-49a2-8c5d-5a7fc58bad2d,size=39642] already in use for an active callback or an InputStream created by ProcessSession.read(FlowFile) has not been closed; rolling back session: {}
18:07:09 UTCERROR9e1d9c5e-0188-1000-ffff-fffffbc25817
10.42.62.250:8080ExecuteScript[id=9e1d9c5e-0188-1000-ffff-fffffbc25817] Processing failed: org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: java.lang.IllegalStateException: java.lang.IllegalStateException: StandardFlowFileRecord[uuid=40d42213-2c7a-49a2-8c5d-5a7fc58bad2d,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1686706804350-73290, container=default, section=586], offset=6556, length=39642],offset=0,name=40d42213-2c7a-49a2-8c5d-5a7fc58bad2d,size=39642] already in use for an active callback or an InputStream created by ProcessSession.read(FlowFile) has not been closed in <script> at line number 37
- Caused by: javax.script.ScriptException: java.lang.IllegalStateException: java.lang.IllegalStateException: StandardFlowFileRecord[uuid=40d42213-2c7a-49a2-8c5d-5a7fc58bad2d,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1686706804350-73290, container=default, section=586], offset=6556, length=39642],offset=0,name=40d42213-2c7a-49a2-8c5d-5a7fc58bad2d,size=39642] already in use for an active callback or an InputStream created by ProcessSession.read(FlowFile) has not been closed in <script> at line number 37
- Caused by: Traceback (most recent call last):
File "<script>", line 37, in <module>
at org.apache.nifi.controller.repository.StandardProcessSession.validateRecordState(StandardProcessSession.java:3715)
at org.apache.nifi.controller.repository.StandardProcessSession.validateRecordState(StandardProcessSession.java:3710)
at org.apache.nifi.controller.repository.StandardProcessSession.transfer(StandardProcessSession.java:2349)
at jdk.internal.reflect.GeneratedMethodAccessor2736.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.IllegalStateException: java.lang.IllegalStateException: StandardFlowFileRecord[uuid=40d42213-2c7a-49a2-8c5d-5a7fc58bad2d,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1686706804350-73290, container=default, section=586], offset=6556, length=39642],offset=0,name=40d42213-2c7a-49a2-8c5d-5a7fc58bad2d,size=39642] already in use for an active callback or an InputStream created by ProcessSession.read(FlowFile) has not been closed
```
I am trying to run following script in NiFi `ExecuteScript` processor
```
import xml.etree.ElementTree as ET
import os
import java.io
from org.apache.commons.io import IOUtils
from java.nio.charset import StandardCharsets
def find_pattern_in_xml(file_path, target_string):
tree = ET.ElementTree(ET.fromstring(file_path))
root = tree.getroot()
found_elements = []
# Iterate through all elements in the XML tree
for element in root.iter():
# Check if the target string is present in the element text
if target_string in element.text:
found_elements.append(element)
return found_elements
flowFile = session.get()
if flowFile is not None:
try:
stream_content = session.read(flowFile)
text_content = IOUtils.toString(stream_content, StandardCharsets.UTF_8)
# flowfile_path = flowFile.getAttribute('sourceFileName')
target_string = "~Indv"
found_elements = find_pattern_in_xml(flowfile_path, target_string)
# Print the found elements
for element in found_elements:
session.remove(flowFile)
print(element.tag, element.text)
except Exception as e:
# Log the error and route the flowfile to failure
log.error("Error processing flowfile"+ str(e))
session.transfer(flowFile, REL_FAILURE)
session.commit()
```
Apache Hadoop and associated open source project names are trademarks of the Apache Software Foundation. For a complete list of trademarks, click here.