Reputation: 1247
I have a custom processor that extends the MergeContent proc and when NiFi starts I have this error in logs:
2016-09-09 18:17:00,607 ERROR [main] org.apache.nifi.NiFi Failure to launch NiFi due to java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider org.apache.nifi.processors.standard.DetectDuplicate could not be instantiated
java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider org.apache.nifi.processors.standard.DetectDuplicate could not be instantiated
at java.util.ServiceLoader.fail(ServiceLoader.java:232) ~[na:1.8.0_101]
at java.util.ServiceLoader.access$100(ServiceLoader.java:185) ~[na:1.8.0_101]
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384) ~[na:1.8.0_101]
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) ~[na:1.8.0_101]
at java.util.ServiceLoader$1.next(ServiceLoader.java:480) ~[na:1.8.0_101]
at org.apache.nifi.nar.ExtensionManager.loadExtensions(ExtensionManager.java:107) ~[nifi-nar-utils-1.0.0.jar:1.0.0]
at org.apache.nifi.nar.ExtensionManager.discoverExtensions(ExtensionManager.java:88) ~[nifi-nar-utils-1.0.0.jar:1.0.0]
at org.apache.nifi.NiFi.<init>(NiFi.java:135) ~[nifi-runtime-1.0.0.jar:1.0.0]
at org.apache.nifi.NiFi.main(NiFi.java:243) ~[nifi-runtime-1.0.0.jar:1.0.0]
Caused by: java.lang.NoClassDefFoundError: org/apache/nifi/distributed/cache/client/Serializer
at java.lang.Class.getDeclaredConstructors0(Native Method) ~[na:1.8.0_101]
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) ~[na:1.8.0_101]
at java.lang.Class.getConstructor0(Class.java:3075) ~[na:1.8.0_101]
at java.lang.Class.newInstance(Class.java:412) ~[na:1.8.0_101]
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380) ~[na:1.8.0_101]
... 6 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.apache.nifi.distributed.cache.client.Serializer
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_101]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_101]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_101]
On Nifi 0.6.1/ 0.7.0 it worked, but when I've tried to use PutSQL proc, I could not see in the property list the DBCPConnectionPool service populated.
Is there a proper way to extend the behaviour of a standard processor ?
Upvotes: 2
Views: 2038
Reputation: 2630
In .pom
from project nifi-mycustom-nar
add following dependency:
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-standard-nar</artifactId>
<version>1.4.0</version>
<type>nar</type>
</dependency>
Note that only one nar dependency is allowed, so if you had nifi-standard-services-api-nar
depdencency, remove it.
In .pom
from project nifi-mycustom-processors
add following dependency:
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-standard-processors</artifactId>
<version>1.4.0</version>
<scope>provided</scope>
</dependency>
Finally, recompile and copy your new nar file into $NIFI/lib
directory.
Upvotes: 2
Reputation: 18670
If you are extending or using components from another NAR in your NAR, there needs to be a NAR dependency between them.
This page demonstrates how to setup the proper linking between a processor and a controller service in separate NARs:
This GitHub project also has a fully working example for the same concept: https://github.com/bbende/nifi-dependency-example
From a dependency perspective, extending a processor and using a controller service should be the same setup, both need to be able to access something from another NAR.
Upvotes: 3