Support Questions

Find answers, ask questions, and share your expertise
Welcome to the upgraded Community! Read this blog to see What’s New!

Calling the store procedure with groovy script in NiFi returns a huge amount of CLOB data, resulting in an error


Hi Team,


I am calling store procedure in Nifi using groovy script. The store procedure contains output parameter which is returning huge CLOB which is in array of json format. I am using below groovy script to call the store procedure 


import org.apache.nifi.controller.ControllerService
import java.nio.charset.*
import groovy.sql.OutParameter
import groovy.sql.Sql
import java.sql.ResultSet
import java.sql.Clob
import static java.sql.Types.CLOB
import java.nio.charset.StandardCharsets
import groovy.json.*

def flowFile = session.get()
if(!flowFile) return
def lookup = context.controllerServiceLookup
def dbServiceName = ConncationPool.value
def dbcpServiceId = lookup.getControllerServiceIdentifiers(ControllerService).find {
cs -> lookup.getControllerServiceName(cs) == dbServiceName

try {

flowFile = session.write(flowFile,
{ inputStream, outputStream ->
def conn = lookup.getControllerService(dbcpServiceId).getConnection();
sql = Sql.newInstance(conn);
String sqlString ="""{call MY_STORE_PROC(?)}""";
def out_param

def parametersList = [Sql.CLOB];, parametersList) {out_json_response ->
out_param = out_json_response
def json = JsonOutput.toJson(out_param)
def parser = new JsonSlurper()
} as StreamCallback)
session.transfer(flowFile, REL_SUCCESS)
} catch(Exception e) {
log.error('Error during JSON operations', e)
session.transfer(flowFile, REL_FAILURE)


But I am getting below error:


failed to process due to org.apache.nifi.processor.exception.ProcessException: java.lang.StackOverflowError

Processing failed: org.apache.nifi.processor.exception.ProcessException: java.lang.StackOverflowError
- Caused by: java.lang.StackOverflowError


Can you please help, I am not getting the CLOB datatype issue.