You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by Sri Harsha Chavali <sr...@outlook.com> on 2019/02/19 12:38:38 UTC

Usage of Custom Controller in InvokeScriptedProcessor

Hi All,

If I have a custom Controller built for a specific use case, could I use the controller in InvokeScriptedProcessor?

I created a custom controller, deployed both api-nar and bundle-nar files, restarted nifi and created controller successfully. Also I see necessary api.jar and bundle.jar files in bundled-dependencies folder of the unpacked nar files in work directory. When I try to import my Service in InvokeScripted processor I get the below error. I assumed the dependencies should be available immediately to NiFi upon nar deployment and restart but looks like they were not available to my processor.

Script1.groovy: 27: unable to resolve class com.test.controller.kudu.KuduService

My controller however got properly created:
[cid:77dc2233-3b8f-4347-ac25-5418b24f97c6]

To solve the issue of my Service Class not being available, I found the unpacked jar file and added the dependent jar file (file containing com/test/controller/kudu/KuduService) to the ISPs  module directory. This makes NiFi's UI crash, except for home page. Please see the screenshots below and error from nifi-user.log below.

ISP with my jar file dependency:
[cid:3f9a988f-87e9-4a94-8f55-3d30e41f644d]

UI Crashed:
[cid:f750709b-fe24-44b6-a19b-9f69a3233f95]
I would also see the below log in nifi-user.log

2019-02-19 01:58:08,909 ERROR [NiFi Web Server-21] o.a.nifi.web.api.config.ThrowableMapper An unexpected error has occurred: java.lang.NullPointerException. Returning Internal Server Error response.
java.lang.NullPointerException: null

Any rookie mistakes experts can see here?

Thank you,
Harsha

Sent from Outlook<http://aka.ms/weboutlook>

Re: Usage of Custom Controller in InvokeScriptedProcessor

Posted by Matt Burgess <ma...@apache.org>.
Harsha,

I don't believe this is possible with InvokeScriptedProcessor, as it needs
access to your controller service interface via its classloader, which it
won't have. For the scripting bundle, we include provided dependencies for
most/all the built-in controller service APIs, and the scripting NAR
inherits from the standard services API NAR, that's how it can access
things like DBCPService. For accessing a custom controller service, the
best approach is probably to just implement your ISP script as its own real
processor, you can even put that in the same bundle/NAR as the custom
controller service. If you're using Groovy you can either port it (fairly
easily) to Java, or include Groovy as a dependency and keep the processor
source in Groovy. The same would go for any other implementation language,
you'd just need to include the corresponding language engine.

Regards,
Matt


On Tue, Feb 19, 2019 at 7:38 AM Sri Harsha Chavali <
sriharsha.chavali@outlook.com> wrote:

> Hi All,
>
> If I have a custom Controller built for a specific use case, could I use
> the controller in InvokeScriptedProcessor?
>
> I created a custom controller, deployed both api-nar and bundle-nar files,
> restarted nifi and created controller successfully. Also I see necessary
> api.jar and bundle.jar files in bundled-dependencies folder of the unpacked
> nar files in work directory. When I try to import my Service in
> InvokeScripted processor I get the below error. I assumed the
> dependencies should be available immediately to NiFi upon nar deployment
> and restart but looks like they were not available to my processor.
>
> *Script1.groovy: 27: unable to resolve class
> com.test.controller.kudu.KuduService*
>
> My controller however got properly created:
>
>
> To solve the issue of my Service Class not being available, I found the
> unpacked jar file and added the dependent jar file (file containing
> com/test/controller/kudu/KuduService) to the ISPs  module directory. This
> makes NiFi's UI crash, except for home page. Please see the screenshots
> below and error from nifi-user.log below.
>
> ISP with my jar file dependency:
>
>
> UI Crashed:
>
> I would also see the below log in nifi-user.log
>
>
> *2019-02-19 01:58:08,909 ERROR [NiFi Web Server-21]
> o.a.nifi.web.api.config.ThrowableMapper An unexpected error has occurred:
> java.lang.NullPointerException. Returning Internal Server Error response. *
> *java.lang.NullPointerException: null*
>
> Any rookie mistakes experts can see here?
>
> Thank you,
> Harsha
>
> Sent from Outlook <http://aka.ms/weboutlook>
>