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

Hello world program of dynamicallyModifiesClasspath() of Apache Nifi properties descriptor not working

Hello world program of dynamicallyModifiesClasspath() of Apache Nifi properties descriptor not working

New Contributor

I have a processor which depends on some jar as a dependency. However changes are made to the dependency jar quite frequenctly. So I want to be able to specify the jar path as a property of processor and let the nifi load the jar each time I modify the path in the property and restart the processor. This is supposed to be doable using dynamicallyModifiesClasspath as explained in this article. However I am unable to do this. Below is my code of hello world program using dynamicallyModifiesClasspath property:

(Below, Djl stands for "dynamic jar loading", a random prefix I guessed to name this hello world program.)

This is the class on which my nifi processor depends and I want to dynamically change its jar path in my nifi processor.

public class DjlDependencyClass {
    public static String getMessage() {
        return "DJL-DEPENDENCY VERSION-1";

This is the nifi processor which depends on DjlDependencyClass.

import org.apache.nifi.annotation.lifecycle.OnScheduled;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.processor.exception.ProcessException;    
import org.apache.nifi.processor.AbstractProcessor;
import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.processor.ProcessSession;
import org.apache.nifi.processor.ProcessorInitializationContext;
import org.apache.nifi.processor.Relationship;
import org.apache.nifi.processor.util.StandardValidators;

import com.mycompany.djldependency.DjlDependencyClass;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class MyDjlProcessor extends AbstractProcessor {

    public static final Relationship MY_RELATIONSHIP = new Relationship.Builder()
            .description("Example relationship")

    public static final PropertyDescriptor pathToDjlDependencyJar = new PropertyDescriptor.Builder()
            .name("Djl Dependency JAR")
            .description("Djl Dependency JAR")
    private List descriptors;
    private Set relationships;
    protected void init(final ProcessorInitializationContext context)
     final List descriptors = new ArrayList();
        this.descriptors = Collections.unmodifiableList(descriptors);
        final Set relationships = new HashSet();
        this.relationships = Collections.unmodifiableSet(relationships);
    public Set getRelationships() {
     return this.relationships;
    public final List getSupportedPropertyDescriptors() {
     return descriptors;
    public void onScheduled(final ProcessContext context) { }
    public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException 

This is how dependency inside pom is marked to have provided scope, so that the dependency jar will not be embedded inside nar:

    <scope>provided </scope>

I am testing this processor as follows:


Configuration of the processor:


I am getting following exception:

2019-05-27 17:01:54,536 ERROR [Timer-Driven Process Thread-1] com.mycompany.djl.MyDjlProcessor MyDjlProcessor[id=f8fa5750-016a-1000-ecc3-c19732119332] MyDjlProcessor[id=f8fa5750-016a-1000-ecc3-c19732119332] failed to process due to java.lang.NoClassDefFoundError: com/mycompany/djldependency/DjlDependencyClass; rolling back session: {}
java.lang.NoClassDefFoundError: com/mycompany/djldependency/DjlDependencyClass    
at com.mycompany.djl.MyDjlProcessor.onTrigger(    
at org.apache.nifi.processor.AbstractProcessor.onTrigger(    
at org.apache.nifi.controller.StandardProcessorNode.onTrigger(    
at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$    
at java.util.concurrent.Executors$    
at java.util.concurrent.FutureTask.runAndReset(    
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(    
at java.util.concurrent.ScheduledThreadPoolExecutor$    
at java.util.concurrent.ThreadPoolExecutor.runWorker(    
at java.util.concurrent.ThreadPoolExecutor$    

Am I doing something stupid here?

Please download both projects (nifi and dependency jar) here.