You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by Russell Bateman <ru...@windofkeltia.com> on 2020/06/22 22:30:34 UTC

Difficulty using DBCPService

I find myself obliged to pick back up a custom processor, written by 
someone else a few years ago (in the NiFi 0.7.x era)  at my company, 
that makes use of DBCPService. While I think I understand the nuances of 
interface versus concrete controller class, etc. I probably need a push 
out the door onto the road of understanding why NiFi is not starting 
(and it's my fault). My JUnit test code works fine; I've created myself 
a loading problem maybe because I'm not including the proper auxiliary 
NAR (in this new, reduced world)? Thanks!

2020-06-22 16:11:37,139 ERROR [main] org.apache.nifi.NiFi Failure to 
launch NiFi due to java.util.ServiceConfigurationError: 
org.apache.nifi.processor.Processor: Provider 
com.imatsolutions.processor.JdbcToAttributes could not be instantiated
java.util.ServiceConfigurationError: 
org.apache.nifi.processor.Processor: Provider 
com.imatsolutions.processor.JdbcToAttributes 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.StandardExtensionDiscoveringManager.loadExtensions(StandardExtensionDiscoveringManager.java:156)
     at 
org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:131)
     at 
org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:117)
     at org.apache.nifi.web.server.JettyServer.start(JettyServer.java:942)
     at org.apache.nifi.NiFi.<init>(NiFi.java:158)
     at org.apache.nifi.NiFi.<init>(NiFi.java:72)
     at org.apache.nifi.NiFi.main(NiFi.java:301)
*Caused by: java.lang.NoClassDefFoundError: 
org/apache/nifi/dbcp/DBCPService*
     at com.imatsolutions.processor.JdbcCommon.<clinit>(JdbcCommon.java:31)
     at 
com.imatsolutions.processor.AbstractJdbcTo.<clinit>(AbstractJdbcTo.java:290)
     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)
     ... 9 common frames omitted
Caused by: java.lang.ClassNotFoundException: 
org.apache.nifi.dbcp.DBCPService
     at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
     ... 17 common frames omitted

I'm doing stuff like this inside my custom processor. (I hope this gives 
enough to go on.)

public class JdbcToAttributes...
{
     public static final PropertyDescriptor DBCP_SERVICE = new 
PropertyDescriptor.Builder()
             .name( "Database Connection Pooling Service" )
             .description( "The controller service that is used to 
obtain connection to database" )
             .required( true )
             .identifiesControllerService( DBCPService.class )
             .build();
   ...

public void onTrigger( final ProcessContext context, final 
ProcessSession session, ProcessSessionFactory factory )
             throws ProcessException
   {
     ...

     final DBCPService dbcpService = context.getProperty( DBCP_SERVICE 
).asControllerService( DBCPService.class );
     etc.




Re: Difficulty using DBCPService

Posted by Russell Bateman <ru...@windofkeltia.com>.
Great. Thanks, Matt. And it is working fine now.

On 6/25/20 10:44 AM, Matt Burgess wrote:
> Russell,
>
> Sorry I lost track of this. If a version of a dependency is not
> provided, then Maven will go up to the parent POM and look for a
> version for it, and so on until it is found. If a version for the
> dependency has not been declared in any parent, you'll get that error
> and need to set the version explicitly in your own POM.
>
> For nifi-dbcp-service-nar, that contains the actual DBCPConnectionPool
> implementation, but your code should (and is) using the interface it
> implements, namely DBCPService. That interface is in
> nifi-standard-services-api-nar, which is why you need it as a parent
> NAR to your custom NAR.
>
> Regards,
> Matt
>
> On Mon, Jun 22, 2020 at 7:52 PM Russell Bateman <ru...@windofkeltia.com> wrote:
>> Putting this dependency in the root, with a version, worked. My processor is loading.
>>
>> Have you the time to tell me how building with this Maven dependency forces the behavior I need? (Or what behavior this is?)
>>
>> I thought that nifi-dbcp-service-nar.nar was already loading before when I tried and looked. I was already checking on that. Maybe I was fooling myself.
>>
>> Thanks, Matt
>>
>> On 6/22/20 5:43 PM, Matt Burgess wrote:
>>
>> You’ll want to add a <version>1.12.0-SNAPSHOT</version> (or a released version of NiFi) before the ending </dependency> tag
>>
>> Sent from my iPhone
>>
>> On Jun 22, 2020, at 7:33 PM, Russell Bateman <ru...@windofkeltia.com> wrote:
>>
>>  Thank you for replying. You speak of the following dependency:
>>
>> <dependency>
>>    <groupId>org.apache.nifi</groupId>
>>    <artifactId>nifi-standard-services-api-nar</artifactId>
>>    <type>nar</type>
>> </dependency>
>>
>>
>> I stumbled upon that, but could not make it work. My multimodule project structure appears thus:
>>
>> -root
>>    - other submodules (whose custom processors work)
>>    - jdbc
>>      pom.xml
>>    - nar
>>      pom.xml
>>    pom.xml
>>
>> No matter which pom.xml above I put that dependency into, I get the following complaint out of Maven:
>>
>> [ERROR]   The project com.imatsolutions.pipeline:jdbc:4.0.0 (/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/jdbc/pom.xml) has 1 error
>>    or
>> [ERROR]   The project com.imatsolutions.pipeline:imat-pipeline:4.0.0 (/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/nar/pom.xml) has 1 error
>>    or
>> [ERROR]   The project com.imatsolutions.pipeline:imat-pipeline-parent:4.0.0 (/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/pom.xml) has 1 error
>> [ERROR]     'dependencies.dependency.version' for org.apache.nifi:nifi-standard-services-api-nar:nar is missing. @ line 136, column 17
>>
>> On 6/22/20 4:38 PM, Matt Burgess wrote:
>>
>> Not at my keyboard but does your NAR have the nifi-standard-services-api-nar as a parent? That should be where DBCPService is defined
>>
>> Sent from my iPhone
>>
>> On Jun 22, 2020, at 6:30 PM, Russell Bateman <ru...@windofkeltia.com> wrote:
>>
>> I find myself obliged to pick back up a custom processor, written by someone else a few years ago (in the NiFi 0.7.x era)  at my company, that makes use of DBCPService. While I think I understand the nuances of interface versus concrete controller class, etc. I probably need a push out the door onto the road of understanding why NiFi is not starting (and it's my fault). My JUnit test code works fine; I've created myself a loading problem maybe because I'm not including the proper auxiliary NAR (in this new, reduced world)? Thanks!
>>
>> 2020-06-22 16:11:37,139 ERROR [main] org.apache.nifi.NiFi Failure to launch NiFi due to java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider com.imatsolutions.processor.JdbcToAttributes could not be instantiated
>> java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider com.imatsolutions.processor.JdbcToAttributes 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.StandardExtensionDiscoveringManager.loadExtensions(StandardExtensionDiscoveringManager.java:156)
>>      at org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:131)
>>      at org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:117)
>>      at org.apache.nifi.web.server.JettyServer.start(JettyServer.java:942)
>>      at org.apache.nifi.NiFi.<init>(NiFi.java:158)
>>      at org.apache.nifi.NiFi.<init>(NiFi.java:72)
>>      at org.apache.nifi.NiFi.main(NiFi.java:301)
>> *Caused by: java.lang.NoClassDefFoundError: org/apache/nifi/dbcp/DBCPService*
>>      at com.imatsolutions.processor.JdbcCommon.<clinit>(JdbcCommon.java:31)
>>      at com.imatsolutions.processor.AbstractJdbcTo.<clinit>(AbstractJdbcTo.java:290)
>>      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)
>>      ... 9 common frames omitted
>> Caused by: java.lang.ClassNotFoundException: org.apache.nifi.dbcp.DBCPService
>>      at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
>>      at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
>>      at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
>>      ... 17 common frames omitted
>>
>> I'm doing stuff like this inside my custom processor. (I hope this gives enough to go on.)
>>
>> public class JdbcToAttributes...
>> {
>>      public static final PropertyDescriptor DBCP_SERVICE = new PropertyDescriptor.Builder()
>>              .name( "Database Connection Pooling Service" )
>>              .description( "The controller service that is used to obtain connection to database" )
>>              .required( true )
>>              .identifiesControllerService( DBCPService.class )
>>              .build();
>>    ...
>>
>> public void onTrigger( final ProcessContext context, final ProcessSession session, ProcessSessionFactory factory )
>>              throws ProcessException
>>    {
>>      ...
>>
>>      final DBCPService dbcpService = context.getProperty( DBCP_SERVICE ).asControllerService( DBCPService.class );
>>      etc.
>>
>>
>>
>>
>>


Re: Difficulty using DBCPService

Posted by Matt Burgess <ma...@gmail.com>.
Russell,

Sorry I lost track of this. If a version of a dependency is not
provided, then Maven will go up to the parent POM and look for a
version for it, and so on until it is found. If a version for the
dependency has not been declared in any parent, you'll get that error
and need to set the version explicitly in your own POM.

For nifi-dbcp-service-nar, that contains the actual DBCPConnectionPool
implementation, but your code should (and is) using the interface it
implements, namely DBCPService. That interface is in
nifi-standard-services-api-nar, which is why you need it as a parent
NAR to your custom NAR.

Regards,
Matt

On Mon, Jun 22, 2020 at 7:52 PM Russell Bateman <ru...@windofkeltia.com> wrote:
>
> Putting this dependency in the root, with a version, worked. My processor is loading.
>
> Have you the time to tell me how building with this Maven dependency forces the behavior I need? (Or what behavior this is?)
>
> I thought that nifi-dbcp-service-nar.nar was already loading before when I tried and looked. I was already checking on that. Maybe I was fooling myself.
>
> Thanks, Matt
>
> On 6/22/20 5:43 PM, Matt Burgess wrote:
>
> You’ll want to add a <version>1.12.0-SNAPSHOT</version> (or a released version of NiFi) before the ending </dependency> tag
>
> Sent from my iPhone
>
> On Jun 22, 2020, at 7:33 PM, Russell Bateman <ru...@windofkeltia.com> wrote:
>
>  Thank you for replying. You speak of the following dependency:
>
> <dependency>
>   <groupId>org.apache.nifi</groupId>
>   <artifactId>nifi-standard-services-api-nar</artifactId>
>   <type>nar</type>
> </dependency>
>
>
> I stumbled upon that, but could not make it work. My multimodule project structure appears thus:
>
> -root
>   - other submodules (whose custom processors work)
>   - jdbc
>     pom.xml
>   - nar
>     pom.xml
>   pom.xml
>
> No matter which pom.xml above I put that dependency into, I get the following complaint out of Maven:
>
> [ERROR]   The project com.imatsolutions.pipeline:jdbc:4.0.0 (/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/jdbc/pom.xml) has 1 error
>   or
> [ERROR]   The project com.imatsolutions.pipeline:imat-pipeline:4.0.0 (/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/nar/pom.xml) has 1 error
>   or
> [ERROR]   The project com.imatsolutions.pipeline:imat-pipeline-parent:4.0.0 (/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/pom.xml) has 1 error
> [ERROR]     'dependencies.dependency.version' for org.apache.nifi:nifi-standard-services-api-nar:nar is missing. @ line 136, column 17
>
> On 6/22/20 4:38 PM, Matt Burgess wrote:
>
> Not at my keyboard but does your NAR have the nifi-standard-services-api-nar as a parent? That should be where DBCPService is defined
>
> Sent from my iPhone
>
> On Jun 22, 2020, at 6:30 PM, Russell Bateman <ru...@windofkeltia.com> wrote:
>
> I find myself obliged to pick back up a custom processor, written by someone else a few years ago (in the NiFi 0.7.x era)  at my company, that makes use of DBCPService. While I think I understand the nuances of interface versus concrete controller class, etc. I probably need a push out the door onto the road of understanding why NiFi is not starting (and it's my fault). My JUnit test code works fine; I've created myself a loading problem maybe because I'm not including the proper auxiliary NAR (in this new, reduced world)? Thanks!
>
> 2020-06-22 16:11:37,139 ERROR [main] org.apache.nifi.NiFi Failure to launch NiFi due to java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider com.imatsolutions.processor.JdbcToAttributes could not be instantiated
> java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider com.imatsolutions.processor.JdbcToAttributes 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.StandardExtensionDiscoveringManager.loadExtensions(StandardExtensionDiscoveringManager.java:156)
>     at org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:131)
>     at org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:117)
>     at org.apache.nifi.web.server.JettyServer.start(JettyServer.java:942)
>     at org.apache.nifi.NiFi.<init>(NiFi.java:158)
>     at org.apache.nifi.NiFi.<init>(NiFi.java:72)
>     at org.apache.nifi.NiFi.main(NiFi.java:301)
> *Caused by: java.lang.NoClassDefFoundError: org/apache/nifi/dbcp/DBCPService*
>     at com.imatsolutions.processor.JdbcCommon.<clinit>(JdbcCommon.java:31)
>     at com.imatsolutions.processor.AbstractJdbcTo.<clinit>(AbstractJdbcTo.java:290)
>     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)
>     ... 9 common frames omitted
> Caused by: java.lang.ClassNotFoundException: org.apache.nifi.dbcp.DBCPService
>     at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
>     ... 17 common frames omitted
>
> I'm doing stuff like this inside my custom processor. (I hope this gives enough to go on.)
>
> public class JdbcToAttributes...
> {
>     public static final PropertyDescriptor DBCP_SERVICE = new PropertyDescriptor.Builder()
>             .name( "Database Connection Pooling Service" )
>             .description( "The controller service that is used to obtain connection to database" )
>             .required( true )
>             .identifiesControllerService( DBCPService.class )
>             .build();
>   ...
>
> public void onTrigger( final ProcessContext context, final ProcessSession session, ProcessSessionFactory factory )
>             throws ProcessException
>   {
>     ...
>
>     final DBCPService dbcpService = context.getProperty( DBCP_SERVICE ).asControllerService( DBCPService.class );
>     etc.
>
>
>
>
>

Re: Difficulty using DBCPService

Posted by Russell Bateman <ru...@windofkeltia.com>.
Putting this dependency in the root, with a version, worked. My 
processor is loading.

Have you the time to tell me how building with this Maven dependency 
forces the behavior I need? (Or what behavior this is?)

I thought that /nifi-dbcp-service-nar.nar/ was already loading before 
when I tried and looked. I was already checking on that. Maybe I was 
fooling myself.

Thanks, Matt

On 6/22/20 5:43 PM, Matt Burgess wrote:
> You’ll want to add a <version>1.12.0-SNAPSHOT</version> (or a released 
> version of NiFi) before the ending </dependency> tag
>
> Sent from my iPhone
>
>> On Jun 22, 2020, at 7:33 PM, Russell Bateman <ru...@windofkeltia.com> 
>> wrote:
>>
>>  Thank you for replying. You speak of the following dependency:
>> <dependency>
>>    <groupId>org.apache.nifi</groupId>
>>    <artifactId>nifi-standard-services-api-nar</artifactId>
>>    <type>nar</type>
>> </dependency>
>>
>> I stumbled upon that, but could not make it work. My multimodule 
>> project structure appears thus:
>>
>> -root
>>   - other submodules (whose custom processors work)
>>   - jdbc
>> *pom.xml*
>>   - nar
>> *pom.xml*
>> *pom.xml*
>>
>> No matter which /pom.xml/ above I put that dependency into, I get the 
>> following complaint out of Maven:
>>
>> [ERROR]   The project com.imatsolutions.pipeline:jdbc:4.0.0 
>> (/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/jdbc/pom.xml) 
>> has 1 error
>>   or
>> [ERROR]   The project com.imatsolutions.pipeline:imat-pipeline:4.0.0 
>> (/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/nar/pom.xml) 
>> has 1 error
>>   or
>> [ERROR]   The project 
>> com.imatsolutions.pipeline:imat-pipeline-parent:4.0.0 
>> (/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/pom.xml) 
>> has 1 error
>> [ERROR]     'dependencies.dependency.version' for 
>> org.apache.nifi:nifi-standard-services-api-nar:nar is missing. @ line 
>> 136, column 17
>>
>> On 6/22/20 4:38 PM, Matt Burgess wrote:
>>> Not at my keyboard but does your NAR have the nifi-standard-services-api-nar as a parent? That should be where DBCPService is defined
>>>
>>> Sent from my iPhone
>>>
>>>> On Jun 22, 2020, at 6:30 PM, Russell Bateman<ru...@windofkeltia.com>  wrote:
>>>>
>>>> I find myself obliged to pick back up a custom processor, written by someone else a few years ago (in the NiFi 0.7.x era)  at my company, that makes use of DBCPService. While I think I understand the nuances of interface versus concrete controller class, etc. I probably need a push out the door onto the road of understanding why NiFi is not starting (and it's my fault). My JUnit test code works fine; I've created myself a loading problem maybe because I'm not including the proper auxiliary NAR (in this new, reduced world)? Thanks!
>>>>
>>>> 2020-06-22 16:11:37,139 ERROR [main] org.apache.nifi.NiFi Failure to launch NiFi due to java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider com.imatsolutions.processor.JdbcToAttributes could not be instantiated
>>>> java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider com.imatsolutions.processor.JdbcToAttributes 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.StandardExtensionDiscoveringManager.loadExtensions(StandardExtensionDiscoveringManager.java:156)
>>>>      at org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:131)
>>>>      at org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:117)
>>>>      at org.apache.nifi.web.server.JettyServer.start(JettyServer.java:942)
>>>>      at org.apache.nifi.NiFi.<init>(NiFi.java:158)
>>>>      at org.apache.nifi.NiFi.<init>(NiFi.java:72)
>>>>      at org.apache.nifi.NiFi.main(NiFi.java:301)
>>>> *Caused by: java.lang.NoClassDefFoundError: org/apache/nifi/dbcp/DBCPService*
>>>>      at com.imatsolutions.processor.JdbcCommon.<clinit>(JdbcCommon.java:31)
>>>>      at com.imatsolutions.processor.AbstractJdbcTo.<clinit>(AbstractJdbcTo.java:290)
>>>>      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)
>>>>      ... 9 common frames omitted
>>>> Caused by: java.lang.ClassNotFoundException: org.apache.nifi.dbcp.DBCPService
>>>>      at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
>>>>      at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
>>>>      at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
>>>>      ... 17 common frames omitted
>>>>
>>>> I'm doing stuff like this inside my custom processor. (I hope this gives enough to go on.)
>>>>
>>>> public class JdbcToAttributes...
>>>> {
>>>>      public static final PropertyDescriptor DBCP_SERVICE = new PropertyDescriptor.Builder()
>>>>              .name( "Database Connection Pooling Service" )
>>>>              .description( "The controller service that is used to obtain connection to database" )
>>>>              .required( true )
>>>>              .identifiesControllerService( DBCPService.class )
>>>>              .build();
>>>>    ...
>>>>
>>>> public void onTrigger( final ProcessContext context, final ProcessSession session, ProcessSessionFactory factory )
>>>>              throws ProcessException
>>>>    {
>>>>      ...
>>>>
>>>>      final DBCPService dbcpService = context.getProperty( DBCP_SERVICE ).asControllerService( DBCPService.class );
>>>>      etc.
>>>>
>>>>
>>>>
>>


Re: Difficulty using DBCPService

Posted by Matt Burgess <ma...@gmail.com>.
You’ll want to add a <version>1.12.0-SNAPSHOT</version> (or a released version of NiFi) before the ending </dependency> tag

Sent from my iPhone

> On Jun 22, 2020, at 7:33 PM, Russell Bateman <ru...@windofkeltia.com> wrote:
> 
>  Thank you for replying. You speak of the following dependency:
> <dependency>
>   <groupId>org.apache.nifi</groupId>
>   <artifactId>nifi-standard-services-api-nar</artifactId>
>   <type>nar</type>
> </dependency>
> 
> I stumbled upon that, but could not make it work. My multimodule project structure appears thus:
> 
> -root
>   - other submodules (whose custom processors work)
>   - jdbc
>     pom.xml
>   - nar
>     pom.xml
> pom.xml
> 
> No matter which pom.xml above I put that dependency into, I get the following complaint out of Maven:
> 
> [ERROR]   The project com.imatsolutions.pipeline:jdbc:4.0.0 (/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/jdbc/pom.xml) has 1 error
>   or
> [ERROR]   The project com.imatsolutions.pipeline:imat-pipeline:4.0.0 (/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/nar/pom.xml) has 1 error
>   or
> [ERROR]   The project com.imatsolutions.pipeline:imat-pipeline-parent:4.0.0 (/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/pom.xml) has 1 error
> [ERROR]     'dependencies.dependency.version' for org.apache.nifi:nifi-standard-services-api-nar:nar is missing. @ line 136, column 17
> 
>> On 6/22/20 4:38 PM, Matt Burgess wrote:
>> Not at my keyboard but does your NAR have the nifi-standard-services-api-nar as a parent? That should be where DBCPService is defined
>> 
>> Sent from my iPhone
>> 
>>> On Jun 22, 2020, at 6:30 PM, Russell Bateman <ru...@windofkeltia.com> wrote:
>>> 
>>> I find myself obliged to pick back up a custom processor, written by someone else a few years ago (in the NiFi 0.7.x era)  at my company, that makes use of DBCPService. While I think I understand the nuances of interface versus concrete controller class, etc. I probably need a push out the door onto the road of understanding why NiFi is not starting (and it's my fault). My JUnit test code works fine; I've created myself a loading problem maybe because I'm not including the proper auxiliary NAR (in this new, reduced world)? Thanks!
>>> 
>>> 2020-06-22 16:11:37,139 ERROR [main] org.apache.nifi.NiFi Failure to launch NiFi due to java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider com.imatsolutions.processor.JdbcToAttributes could not be instantiated
>>> java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider com.imatsolutions.processor.JdbcToAttributes 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.StandardExtensionDiscoveringManager.loadExtensions(StandardExtensionDiscoveringManager.java:156)
>>>     at org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:131)
>>>     at org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:117)
>>>     at org.apache.nifi.web.server.JettyServer.start(JettyServer.java:942)
>>>     at org.apache.nifi.NiFi.<init>(NiFi.java:158)
>>>     at org.apache.nifi.NiFi.<init>(NiFi.java:72)
>>>     at org.apache.nifi.NiFi.main(NiFi.java:301)
>>> *Caused by: java.lang.NoClassDefFoundError: org/apache/nifi/dbcp/DBCPService*
>>>     at com.imatsolutions.processor.JdbcCommon.<clinit>(JdbcCommon.java:31)
>>>     at com.imatsolutions.processor.AbstractJdbcTo.<clinit>(AbstractJdbcTo.java:290)
>>>     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)
>>>     ... 9 common frames omitted
>>> Caused by: java.lang.ClassNotFoundException: org.apache.nifi.dbcp.DBCPService
>>>     at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
>>>     at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
>>>     at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
>>>     ... 17 common frames omitted
>>> 
>>> I'm doing stuff like this inside my custom processor. (I hope this gives enough to go on.)
>>> 
>>> public class JdbcToAttributes...
>>> {
>>>     public static final PropertyDescriptor DBCP_SERVICE = new PropertyDescriptor.Builder()
>>>             .name( "Database Connection Pooling Service" )
>>>             .description( "The controller service that is used to obtain connection to database" )
>>>             .required( true )
>>>             .identifiesControllerService( DBCPService.class )
>>>             .build();
>>>   ...
>>> 
>>> public void onTrigger( final ProcessContext context, final ProcessSession session, ProcessSessionFactory factory )
>>>             throws ProcessException
>>>   {
>>>     ...
>>> 
>>>     final DBCPService dbcpService = context.getProperty( DBCP_SERVICE ).asControllerService( DBCPService.class );
>>>     etc.
>>> 
>>> 
>>> 
> 

Re: Difficulty using DBCPService

Posted by Russell Bateman <ru...@windofkeltia.com>.
Thank you for replying. You speak of the following dependency:

<dependency>
   <groupId>org.apache.nifi</groupId>
   <artifactId>nifi-standard-services-api-nar</artifactId>
   <type>nar</type>
</dependency>


I stumbled upon that, but could not make it work. My multimodule project 
structure appears thus:

-root
   - other submodules (whose custom processors work)
   - jdbc
*pom.xml*
   - nar
*pom.xml*
*pom.xml*

No matter which /pom.xml/ above I put that dependency into, I get the 
following complaint out of Maven:

[ERROR]   The project com.imatsolutions.pipeline:jdbc:4.0.0 
(/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/jdbc/pom.xml) 
has 1 error
   or
[ERROR]   The project com.imatsolutions.pipeline:imat-pipeline:4.0.0 
(/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/nar/pom.xml) 
has 1 error
   or
[ERROR]   The project 
com.imatsolutions.pipeline:imat-pipeline-parent:4.0.0 
(/home/russ/sandboxes/imat-pipeline.master.dev/code/imat-pipeline/pom.xml) 
has 1 error
[ERROR]     'dependencies.dependency.version' for 
org.apache.nifi:nifi-standard-services-api-nar:nar is missing. @ line 
136, column 17

On 6/22/20 4:38 PM, Matt Burgess wrote:
> Not at my keyboard but does your NAR have the nifi-standard-services-api-nar as a parent? That should be where DBCPService is defined
>
> Sent from my iPhone
>
>> On Jun 22, 2020, at 6:30 PM, Russell Bateman <ru...@windofkeltia.com> wrote:
>>
>> I find myself obliged to pick back up a custom processor, written by someone else a few years ago (in the NiFi 0.7.x era)  at my company, that makes use of DBCPService. While I think I understand the nuances of interface versus concrete controller class, etc. I probably need a push out the door onto the road of understanding why NiFi is not starting (and it's my fault). My JUnit test code works fine; I've created myself a loading problem maybe because I'm not including the proper auxiliary NAR (in this new, reduced world)? Thanks!
>>
>> 2020-06-22 16:11:37,139 ERROR [main] org.apache.nifi.NiFi Failure to launch NiFi due to java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider com.imatsolutions.processor.JdbcToAttributes could not be instantiated
>> java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider com.imatsolutions.processor.JdbcToAttributes 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.StandardExtensionDiscoveringManager.loadExtensions(StandardExtensionDiscoveringManager.java:156)
>>      at org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:131)
>>      at org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:117)
>>      at org.apache.nifi.web.server.JettyServer.start(JettyServer.java:942)
>>      at org.apache.nifi.NiFi.<init>(NiFi.java:158)
>>      at org.apache.nifi.NiFi.<init>(NiFi.java:72)
>>      at org.apache.nifi.NiFi.main(NiFi.java:301)
>> *Caused by: java.lang.NoClassDefFoundError: org/apache/nifi/dbcp/DBCPService*
>>      at com.imatsolutions.processor.JdbcCommon.<clinit>(JdbcCommon.java:31)
>>      at com.imatsolutions.processor.AbstractJdbcTo.<clinit>(AbstractJdbcTo.java:290)
>>      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)
>>      ... 9 common frames omitted
>> Caused by: java.lang.ClassNotFoundException: org.apache.nifi.dbcp.DBCPService
>>      at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
>>      at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
>>      at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
>>      ... 17 common frames omitted
>>
>> I'm doing stuff like this inside my custom processor. (I hope this gives enough to go on.)
>>
>> public class JdbcToAttributes...
>> {
>>      public static final PropertyDescriptor DBCP_SERVICE = new PropertyDescriptor.Builder()
>>              .name( "Database Connection Pooling Service" )
>>              .description( "The controller service that is used to obtain connection to database" )
>>              .required( true )
>>              .identifiesControllerService( DBCPService.class )
>>              .build();
>>    ...
>>
>> public void onTrigger( final ProcessContext context, final ProcessSession session, ProcessSessionFactory factory )
>>              throws ProcessException
>>    {
>>      ...
>>
>>      final DBCPService dbcpService = context.getProperty( DBCP_SERVICE ).asControllerService( DBCPService.class );
>>      etc.
>>
>>
>>


Re: Difficulty using DBCPService

Posted by Matt Burgess <ma...@gmail.com>.
Not at my keyboard but does your NAR have the nifi-standard-services-api-nar as a parent? That should be where DBCPService is defined

Sent from my iPhone

> On Jun 22, 2020, at 6:30 PM, Russell Bateman <ru...@windofkeltia.com> wrote:
> 
> I find myself obliged to pick back up a custom processor, written by someone else a few years ago (in the NiFi 0.7.x era)  at my company, that makes use of DBCPService. While I think I understand the nuances of interface versus concrete controller class, etc. I probably need a push out the door onto the road of understanding why NiFi is not starting (and it's my fault). My JUnit test code works fine; I've created myself a loading problem maybe because I'm not including the proper auxiliary NAR (in this new, reduced world)? Thanks!
> 
> 2020-06-22 16:11:37,139 ERROR [main] org.apache.nifi.NiFi Failure to launch NiFi due to java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider com.imatsolutions.processor.JdbcToAttributes could not be instantiated
> java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider com.imatsolutions.processor.JdbcToAttributes 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.StandardExtensionDiscoveringManager.loadExtensions(StandardExtensionDiscoveringManager.java:156)
>     at org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:131)
>     at org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:117)
>     at org.apache.nifi.web.server.JettyServer.start(JettyServer.java:942)
>     at org.apache.nifi.NiFi.<init>(NiFi.java:158)
>     at org.apache.nifi.NiFi.<init>(NiFi.java:72)
>     at org.apache.nifi.NiFi.main(NiFi.java:301)
> *Caused by: java.lang.NoClassDefFoundError: org/apache/nifi/dbcp/DBCPService*
>     at com.imatsolutions.processor.JdbcCommon.<clinit>(JdbcCommon.java:31)
>     at com.imatsolutions.processor.AbstractJdbcTo.<clinit>(AbstractJdbcTo.java:290)
>     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)
>     ... 9 common frames omitted
> Caused by: java.lang.ClassNotFoundException: org.apache.nifi.dbcp.DBCPService
>     at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
>     ... 17 common frames omitted
> 
> I'm doing stuff like this inside my custom processor. (I hope this gives enough to go on.)
> 
> public class JdbcToAttributes...
> {
>     public static final PropertyDescriptor DBCP_SERVICE = new PropertyDescriptor.Builder()
>             .name( "Database Connection Pooling Service" )
>             .description( "The controller service that is used to obtain connection to database" )
>             .required( true )
>             .identifiesControllerService( DBCPService.class )
>             .build();
>   ...
> 
> public void onTrigger( final ProcessContext context, final ProcessSession session, ProcessSessionFactory factory )
>             throws ProcessException
>   {
>     ...
> 
>     final DBCPService dbcpService = context.getProperty( DBCP_SERVICE ).asControllerService( DBCPService.class );
>     etc.
> 
> 
>