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

Cannot resolve org.apache.nifi:nifi-standard-services-api-nar - How to use LookupService inside CustomProcessor

New Contributor

I have posted this question on [stackoverflow](https://stackoverflow.com/questions/66951167/cannot-resolve-org-apache-nifinifi-standard-services-ap... if more details required.

 

Simply I need to create a custom processor to decode certain types of binary files and during the decoding I need to lookup CSV file. I know I can use `CSVRecordLookupService` similar to what NiFi `LookupRecord` processor does. for this I need to refer `org.apache.nifi.lookup.LookupService` inside my code. 

My question is how to refer this class as it is not available in default packages that was added when creating custom processor. So I searched the maven repository and found this [NiFi Standard Services API NAR](https://mvnrepository.com/artifact/org.apache.nifi/nifi-standard-services-api-nar/1.13.0)

 

Problem with this package is it is `nar` and not a `jar`, even though my editor (IDEA) is fine adding it to the project and I also can refer it within my code, I cannot build my `nar` using maven as it gives the below error

 

`Cannot resolve org.apache.nifi:nifi-standard-services-api-nar:1.13.0`

 

So my question is how or best way to use `LookupService` class inside my custom processor during compile and build time and then use NiFi provided class at run time. How to build my `nar` without the above error

 

1 REPLY 1

Re: Cannot resolve org.apache.nifi:nifi-standard-services-api-nar - How to use LookupService inside CustomProcessor

New Contributor

I'd like to provide an update on this, but the issue is not fully resolved.

I found a jar in [maven repo](https://mvnrepository.com/artifact/org.apache.nifi/nifi-lookup-service-api/1.13.0) which has the `LookupService`

 

This together with [org.apache.nifi.serialization.record.Record](https://mvnrepository.com/artifact/org.apache.nifi/nifi-record) I can compile and run the maven successfully. 

 

According to maven repo dependency both these should be declared with the scope `provided`. So I did that.

In my processor now I have `LookupService` used as follows.

 

public static final PropertyDescriptor CLIENT_LOOKUP_SERVICE =
new PropertyDescriptor.Builder()
.name("Client CSV Lookup service")
.identifiesControllerService(LookupService.class)
.required(true)
.build();

Also in the onShedule() I use it as follows

    @Override
    public void onScheduled(ProcessContext context) {
        this.clientNiFiLookupService = context.getProperty(CLIENT_LOOKUP_SERVICE).asControllerService(LookupService.class);
}

Now the problem is I cannot package the nar. It doesn't like the I excluded the LookupService class. even if I remove provided scope it doesn't get included as well.

 

[INFO] Generating documentation for NiFi extensions in the NAR...
[INFO] Found a dependency on version 1.13.0 of NiFi API
[ERROR] Could not generate extensions' documentation
java.lang.NoClassDefFoundError: org/apache/nifi/lookup/LookupService

...
...

[ERROR] Failed to execute goal org.apache.nifi:nifi-nar-maven-plugin:1.3.1:nar (default-nar) on project nifi-decoder-processors-nar: Execution default-nar of goal org.apache.nifi:nifi-nar-maven-plugin:1.3.1:nar failed: A required class was missing while executing org.apache.nifi:nifi-nar-maven-plugin:1.3.1:nar: org/apache/nifi/lookup/LookupService
[ERROR] -----------------------------------------------------
[ERROR] realm =    extension>org.apache.nifi:nifi-nar-maven-plugin:1.3.1

 

So how do we use this LookupService in our custom processors?