Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Nifi startup error after introducing custom processor

Solved Go to solution

Nifi startup error after introducing custom processor

New Contributor

Hi

I have added the below PropertyDescriptor to my custom processor to be able to use Mongo connection pool. however, Nifi wont start. Below errors are generated. can you advise ?

I included the below dependencies as well.

  
  <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-mongodb-client-service-api</artifactId>
            <version>1.8.0</version>
            <type>jar</type>
        </dependency>
        


import org.apache.nifi.mongodb.MongoDBClientService;
     static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder()
        .name("mongo-client-service")
        .displayName("Client Service")
        .description("If configured, this property will use the assigned client service for connection pooling.")
        .required(true)
        .identifiesControllerService(MongoDBClientService.class)
        .build();

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}
span.Apple-tab-span {white-space:pre}



2018-12-17 09:01:49,569 INFO [main] org.apache.nifi.web.server.JettyServer Loading WAR: /opt/nifi-1.8.0/./work/nar/framework/nifi-framework-nar-1.8.0.nar-unpacked/NAR-INF/bundled-dependencies/nifi-web-error-1.8.0.war with context path set to /

2018-12-17 09:01:49,638 INFO [main] org.apache.nifi.web.server.JettyServer Running in HTTP mode; host headers not restricted

2018-12-17 09:01:50,945 ERROR [main] org.apache.nifi.NiFi Failure to launch NiFi due to java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider nifi.processors.nifi.MyProcessor could not be instantiated

java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider nifi.processors.nifi.MyProcessor could not be instantiated

	at java.util.ServiceLoader.fail(ServiceLoader.java:232)

	at java.util.ServiceLoader.access$100(ServiceLoader.java:185)

	at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384)

	at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)

	at java.util.ServiceLoader$1.next(ServiceLoader.java:480)

	at org.apache.nifi.nar.ExtensionManager.loadExtensions(ExtensionManager.java:148)

	at org.apache.nifi.nar.ExtensionManager.discoverExtensions(ExtensionManager.java:123)

	at org.apache.nifi.web.server.JettyServer.start(JettyServer.java:838)

	at org.apache.nifi.NiFi.<init>(NiFi.java:157)

	at org.apache.nifi.NiFi.<init>(NiFi.java:71)

	at org.apache.nifi.NiFi.main(NiFi.java:296)

Caused by: java.lang.NoClassDefFoundError: org/apache/nifi/mongodb/MongoDBClientService

	at nifi.processors.nifi.MyProcessor.<clinit>(MyProcessor.java:79)

	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

	at java.lang.Class.newInstance(Class.java:442)

	at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)

	... 8 common frames omitted

Caused by: java.lang.ClassNotFoundException: org.apache.nifi.mongodb.MongoDBClientService

	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)

	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

	... 15 common frames omitted

2018-12-17 09:01:50,952 INFO [Thread-1] org.apache.nifi.NiFi Initiating shutdown of Jetty web server...

2018-12-17 09:01:50,954 INFO [Thread-1] org.apache.nifi.NiFi Jetty web server shutdown completed (nicely or otherwise).

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Nifi startup error after introducing custom processor

Contributor
<dependency>
    <groupId>org.apache.nifi</groupId>
    <artifactId>nifi-mongodb-client-service-api</artifactId>
    <scope>provided</scope>
</dependency>

Your dependency should be that.

You also need to have a NAR dependency

<packaging>nar</packaging>
<dependencies>
    <dependency>
        <groupId>org.apache.nifi</groupId>
        <artifactId>nifi-mongodb-client-service-api-nar</artifactId>
        <version>1.8.0</version>
        <type>nar</type>
    </dependency>
2 REPLIES 2

Re: Nifi startup error after introducing custom processor

Contributor
<dependency>
    <groupId>org.apache.nifi</groupId>
    <artifactId>nifi-mongodb-client-service-api</artifactId>
    <scope>provided</scope>
</dependency>

Your dependency should be that.

You also need to have a NAR dependency

<packaging>nar</packaging>
<dependencies>
    <dependency>
        <groupId>org.apache.nifi</groupId>
        <artifactId>nifi-mongodb-client-service-api-nar</artifactId>
        <version>1.8.0</version>
        <type>nar</type>
    </dependency>

Re: Nifi startup error after introducing custom processor

New Contributor

Thank you @Otto Fowler

I changed it as per your advice. However, I still face the same issue. For some reason, project doesnt include all the pom jar/nar

Below is my pom.xml


<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>nifi</groupId> <artifactId>custom1</artifactId> <version>1.8.0</version> </parent> <artifactId>nifi-nifi-processors</artifactId> <packaging>nar</packaging> <dependencies> <dependency> <groupId>org.apache.nifi</groupId> <artifactId>nifi-api</artifactId> <version>1.8.0</version> <type>jar</type> </dependency> <dependency> <groupId>org.apache.nifi</groupId> <artifactId>nifi-utils</artifactId> <version>1.8.0</version> </dependency> <dependency> <groupId>org.apache.nifi</groupId> <artifactId>nifi-mock</artifactId> <version>1.8.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> <version>3.2.2</version> </dependency> <dependency> <groupId>org.apache.nifi</groupId> <artifactId>nifi-mongodb-client-service-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.nifi</groupId> <artifactId>nifi-mongodb-client-service-api-nar</artifactId> <version>1.8.0</version> <type>nar</type> </dependency> <dependency> <groupId>org.apache.nifi</groupId> <artifactId>nifi-ssl-context-service-api</artifactId> <version>1.8.0</version> <type>jar</type> </dependency> </dependencies> <version>1.8.0</version> </project>
Don't have an account?
Coming from Hortonworks? Activate your account here