Support Questions
Find answers, ask questions, and share your expertise

Why is my NiFi controllerService null?

Why is my NiFi controllerService null?

Explorer

Hi,


I'm writing a Groovy script in which I would like to execute a query to a PostgreSQL database. To do so, I've configured a Controller Service following the instructions here indicated: http://funnifi.blogspot.com/2016/04/sql-in-nifi-with-executescript.html, and here you can see my own configuration:

108371-captura-de-pantalla-2019-04-29-a-las-170828.png

Later, I've followed the instructions to reference this controller from the groovy script. Specifically, this are the lines that I have added to my script:


def lookup = context.controllerServiceLookup

def dbServiceName = databaseConnectionPoolName.value

def dbcpServiceId = lookup.getControllerServiceIdentifiers(ControllerService).find {

cs -> lookup.getControllerServiceName(cs) == dbServiceName

}

def conn = lookup.getControllerService(dbcpServiceId).getConnection()

Anyway, I'm receiving a "Cannot invoke method getConnection() on null object". Trying to debug to get to the problem, I've substituted dbcpServiceId in line def conn = lookup.getControllerService(dbcpServiceId).getConnection() with its literal value, so my line turns this way: def conn = lookup.getControllerService('6966346c-016a-1000-51f5-283beccda10c').getConnection(). Unfortunately, the result is the same.


How can a controller service be null, and which could be the solution?


Thanks for your help.