Support Questions

Find answers, ask questions, and share your expertise

Custom NiFi processor gets "ControllerServices may be referenced only via their interfaces" error.

avatar
Contributor

I have built a custom controller service and custom processor. I am able to build and run tests in IntelliJ on my laptop. Once the maven build is successfully complete, I copied all the 3 nar files and dropped them in the lib folder of NiFi.

In NiFi web interface, I can the see my custom service in Controller Service page. I am able to configure it and enable it. NiFi logs confirms the service is online. Now, when I drop the custom processor, I cannot see the service to choose in drop down. Event though it is service is running.

I verified the dependencies in pom for all nar modules.

  1. nifi-customservice-api-nar
  2. nifi-customservice-nar
  3. nifi-LookupProcessor-nar

Following is the error in the NiFi app log:

java.lang.IllegalArgumentException: ControllerServices may be referenced only via their interfaces; class org.pwc.nifi.customservice.LookupService is not an interface at org.apache.nifi.attribute.expression.language.StandardPropertyValue.asControllerService(StandardPropertyValue.java:172) ~[nifi-expression-language-1.1.1.jar:1.1.1] at org.pwc.nifi.customservice.LookupProcessor.onTrigger(LookupProcessor.java:79) ~[na:na] at org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27) ~[nifi-api-1.1.1.jar:1.1.1] at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1099) ~[nifi-framework-core-1.1.1.jar:1.1.1] at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:136) [nifi-framework-core-1.1.1.jar:1.1.1] at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:47) [nifi-framework-core-1.1.1.jar:1.1.1] at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:132) [nifi-framework-core-1.1.1.jar:1.1.1] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [na:1.8.0_91] at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [na:1.8.0_91] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) [na:1.8.0_91] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [na:1.8.0_91] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_91] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_91] at java.lang.Thread.run(Unknown Source) [na:1.8.0_91]

I would appreciate if someone can help with :

  1. Resolving missing service in drop down when configuring the processor in properties.
  2. Resolving error "java.lang.IllegalArgumentException: ControllerServices may be referenced only via their interfaces"

Thank you.

1 ACCEPTED SOLUTION

avatar
Master Guru

It is hard to tell without being able to see your code, but it seems like this is saying that in LookupProcessor you have a PropertyDescriptor that represents a Controller Service, but the class you specified is not the interface from nifi-customservice-api-nar, but instead it is the implementation from nifi-customservice-nar.

As an example, InvokeHttp uses SSLContextService:

https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-proce...

SSLContextService is the interface that comes from nifi-standard-services-api:

https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-standard-services/nifi-ssl-context-...

The implementation is StandardSSLContextService which is is nifi-ssl-context-bundle:

https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-standard-services/nifi-ssl-context-...

View solution in original post

2 REPLIES 2

avatar
Master Guru

It is hard to tell without being able to see your code, but it seems like this is saying that in LookupProcessor you have a PropertyDescriptor that represents a Controller Service, but the class you specified is not the interface from nifi-customservice-api-nar, but instead it is the implementation from nifi-customservice-nar.

As an example, InvokeHttp uses SSLContextService:

https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-proce...

SSLContextService is the interface that comes from nifi-standard-services-api:

https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-standard-services/nifi-ssl-context-...

The implementation is StandardSSLContextService which is is nifi-ssl-context-bundle:

https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-standard-services/nifi-ssl-context-...

avatar
Contributor

Your explanation helped me in identify the core issue. You are correct in assuming I was calling the service implementation rather than the interface. Once I made appropriate changes in my code and unit tested, I was able to drop in NiFi and have the integration testing done.

I was able to configure the custom service by adding it in drop down on the custom Lookup processor in NiFi Web UI.

THANK YOU for all the help!!!!