Dhanushka Dolapihilla
Dhanushka Dolapihilla

Reputation: 1145

Apache Nifi failure due to java.lang.NoClassDefFoundError in a local maven dependency jar.

This is the first time I am using maven, I want to implement a processor for apache-nifi. Now for this I am using a proprietary jar file which is an SDK. It is not on the repositories. Therefore i have put it in the pom.xml as follows.

<dependency>
        <groupId>KS</groupId>
        <artifactId>En-SDK</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/lib/En-SDK-Java.jar</systemPath>
</dependency>

I am using intelliJ which seem to have no problem importing this dependency. So is the maven build procedure.

I use mvn clean install as explained in this tutorial. Which gives me with a nar package as the output. (no build errors)

This nar , which is supposed to be put in the $NIFI_HOME/lib directory does not bundle the said local jar.

If i place this nar file in the required directory and start apache-nifi,

 INFO [main] org.apache.nifi.nar.NarClassLoaders Loaded NAR file: /..././work/nar/extensions/myNar.nar

Seems to be loaded by the NarClassLoaders , but following that I get an exception and nifi doesn't start.

java.lang.NoClassDefFoundError: com/kls/../../SubscriptionInterface

The SubscriptionInterface is a class from the said local jar.

If I look at the nar file's folder structure, inside the META-INF/bundled-dependencies/ i see every other dependant jar files defined in the pom but not this local jar i used.

How to overcome this?

Upvotes: 1

Views: 2389

Answers (1)

LeoN
LeoN

Reputation: 1628

The following Stackoverflow question seems to be similar to what you have asked. Maven 2 assembly with dependencies: jar under scope "system" not included

Try to put the dependency in a local repository and declare it in the pom.

Upvotes: 2

Related Questions