You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by Sam Preston <sp...@researchinnovations.com> on 2017/03/31 02:43:50 UTC

Custom implementation of standard Controller Service interface

Hi all,

I'm having some trouble getting a custom Controller Service implementing
DistributedMapCacheClient working.  In short, when I try to use my custom
implementation with an existing processor that uses a
DistributedMapCacheClient controller service, I get an error that  "<id> is
not a valid Controller Service Identifier or does not reference the correct
type of Controller Service.":

[image: pasted5]
However, if I use my own custom processor (defined in the same project)
using a DistributedMapCacheClient, everything works as expected.  I'm
guessing this is a classloading issue, as the standard processor doesn't
seem to recognize that my service implements DistributedMapCacheClient.
I've tried setting the scope of the maven
nifi-distributed-cache-client-service-api dependency to 'provided', but
then I get a ClassNotFoundError for DistributedMapCacheClient.

I've set up a simple test project in order to debug (modified from an
example project of creating a custom controller service):

https://github.com/jspreston/nifi-examples/tree/sample-processor

Does anyone see what I'm doing wrong, or have an example of implementing an
existing controller service interface in a separate nar?

Some more info:

I'm using nifi 1.1.1.

In either the custom or standard processor case, the new controller service
shows up in the dropdown for creating a new controller service from the
processor property:

[image: pasted7]

In the case of the custom processor (DoNothingCacheTestProcessor), I can
create the new service and everything works as expected:
[image: pasted8]
However, in the standard processor (FetchDistributedMapCache), create fails
and I just get the processor ID showing:

[image: pasted9]

Thanks for any insights,
-Sam

Re: Custom implementation of standard Controller Service interface

Posted by Sam Preston <sp...@researchinnovations.com>.
Hi Joe,

Thanks, that was indeed the problem.  Now the same classloader is used to
load the interface in the custom controller service and the standard
processors, and everything works as expected.

-Sam

On Thu, Mar 30, 2017 at 11:07 PM Joe Witt <jo...@gmail.com> wrote:

> one quick thing i noticed.  Believe you'll need your nar's pom.xml to
> depend on the standard-services-api-nar which defines the class for
> DistributedMapCache.  As shown here
>
>
> https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-nar/pom.xml#L30-L34
>
>
> On Thu, Mar 30, 2017 at 10:43 PM, Sam Preston <
> spreston@researchinnovations.com> wrote:
>
> Hi all,
>
> I'm having some trouble getting a custom Controller Service implementing
> DistributedMapCacheClient working.  In short, when I try to use my custom
> implementation with an existing processor that uses a
> DistributedMapCacheClient controller service, I get an error that  "<id> is
> not a valid Controller Service Identifier or does not reference the correct
> type of Controller Service.":
>
> [image: pasted5]
> However, if I use my own custom processor (defined in the same project)
> using a DistributedMapCacheClient, everything works as expected.  I'm
> guessing this is a classloading issue, as the standard processor doesn't
> seem to recognize that my service implements DistributedMapCacheClient.
> I've tried setting the scope of the maven
> nifi-distributed-cache-client-service-api dependency to 'provided', but
> then I get a ClassNotFoundError for DistributedMapCacheClient.
>
> I've set up a simple test project in order to debug (modified from an
> example project of creating a custom controller service):
>
> https://github.com/jspreston/nifi-examples/tree/sample-processor
>
> Does anyone see what I'm doing wrong, or have an example of implementing
> an existing controller service interface in a separate nar?
>
> Some more info:
>
> I'm using nifi 1.1.1.
>
> In either the custom or standard processor case, the new controller
> service shows up in the dropdown for creating a new controller service from
> the processor property:
>
> [image: pasted7]
>
> In the case of the custom processor (DoNothingCacheTestProcessor), I can
> create the new service and everything works as expected:
> [image: pasted8]
> However, in the standard processor (FetchDistributedMapCache), create
> fails and I just get the processor ID showing:
>
> [image: pasted9]
>
> Thanks for any insights,
> -Sam
>
>
>

Re: Custom implementation of standard Controller Service interface

Posted by Joe Witt <jo...@gmail.com>.
one quick thing i noticed.  Believe you'll need your nar's pom.xml to
depend on the standard-services-api-nar which defines the class for
DistributedMapCache.  As shown here


https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-nar/pom.xml#L30-L34


On Thu, Mar 30, 2017 at 10:43 PM, Sam Preston <
spreston@researchinnovations.com> wrote:

> Hi all,
>
> I'm having some trouble getting a custom Controller Service implementing
> DistributedMapCacheClient working.  In short, when I try to use my custom
> implementation with an existing processor that uses a
> DistributedMapCacheClient controller service, I get an error that  "<id> is
> not a valid Controller Service Identifier or does not reference the correct
> type of Controller Service.":
>
> [image: pasted5]
> However, if I use my own custom processor (defined in the same project)
> using a DistributedMapCacheClient, everything works as expected.  I'm
> guessing this is a classloading issue, as the standard processor doesn't
> seem to recognize that my service implements DistributedMapCacheClient.
> I've tried setting the scope of the maven nifi-distributed-cache-client-service-api
> dependency to 'provided', but then I get a ClassNotFoundError for
> DistributedMapCacheClient.
>
> I've set up a simple test project in order to debug (modified from an
> example project of creating a custom controller service):
>
> https://github.com/jspreston/nifi-examples/tree/sample-processor
>
> Does anyone see what I'm doing wrong, or have an example of implementing
> an existing controller service interface in a separate nar?
>
> Some more info:
>
> I'm using nifi 1.1.1.
>
> In either the custom or standard processor case, the new controller
> service shows up in the dropdown for creating a new controller service from
> the processor property:
>
> [image: pasted7]
>
> In the case of the custom processor (DoNothingCacheTestProcessor), I can
> create the new service and everything works as expected:
> [image: pasted8]
> However, in the standard processor (FetchDistributedMapCache), create
> fails and I just get the processor ID showing:
>
> [image: pasted9]
>
> Thanks for any insights,
> -Sam
>
>