Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Why is my NiFi controllerService null?

Highlighted

Why is my NiFi controllerService null?

New Contributor

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.


Don't have an account?
Coming from Hortonworks? Activate your account here