Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Want to read NIFI template data in run time.

avatar
Rising Star

Hello,

I am going to make a custom processor which needs NIFI template xml file's data(existing saved template) in run time, is this possible in nifi to read existing nifi template file's data in run time.

Thanks

1 ACCEPTED SOLUTION

avatar
Master Guru

That's interesting.

You can read it just like a regular XML with a SAX or DOM parser like Jackson.

What do you need from the XML?

You could read configuration file elsewhere or pass it into your processor.

https://nifi.apache.org/developer-guide.html

View solution in original post

2 REPLIES 2

avatar
Master Guru

That's interesting.

You can read it just like a regular XML with a SAX or DOM parser like Jackson.

What do you need from the XML?

You could read configuration file elsewhere or pass it into your processor.

https://nifi.apache.org/developer-guide.html

avatar
Rising Star

Thanks Timothy

I have find out the way to read template's xml file in onTrigger method of my custom processor, but I am getting some issues.

I am using getTemplates() method of StandardNiFiServiceFacade class that implements NiFiServiceFacade interface, and I make object of that interface like this --

private NiFiServiceFacade serviceFacade = new StandardNiFiServiceFacade();

in my custom processor's code. But when I am going to up my nifi server, I got error on this line.

Below are the error I am getting:

java.util.ServiceConfigurationError: org.apache.nifi.processor.Processor: Provider org.apache.nifi.processors.hadoop.SparkConnector could not be instantiated at java.util.ServiceLoader.fail(ServiceLoader.java:232) ~[na:1.8.0_111] at java.util.ServiceLoader.access$100(ServiceLoader.java:185) ~[na:1.8.0_111] at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384) ~[na:1.8.0_111] at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) ~[na:1.8.0_111] at java.util.ServiceLoader$1.next(ServiceLoader.java:480) ~[na:1.8.0_111] at org.apache.nifi.nar.ExtensionManager.loadExtensions(ExtensionManager.java:116) ~[nifi-nar-utils-1.1.2.jar:1.1.2] at org.apache.nifi.nar.ExtensionManager.discoverExtensions(ExtensionManager.java:97) ~[nifi-nar-utils-1.1.2.jar:1.1.2] at org.apache.nifi.NiFi.<init>(NiFi.java:139) ~[nifi-runtime-1.1.2.jar:1.1.2] at org.apache.nifi.NiFi.main(NiFi.java:262) ~[nifi-runtime-1.1.2.jar:1.1.2]

Caused by: java.lang.NoClassDefFoundError: org/apache/nifi/web/revision/RevisionClaim at org.apache.nifi.processors.hadoop.SparkConnector.<init>(SparkConnector.java:53) ~[nifi-hdfs-processors-1.1.2.jar:1.1.2] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_111] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_111] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_111] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_111] at java.lang.Class.newInstance(Class.java:442) ~[na:1.8.0_111] at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380) ~[na:1.8.0_111] ... 6 common frames omitted

Caused by: java.lang.ClassNotFoundException: org.apache.nifi.web.revision.RevisionClaim at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_111] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_111] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_111] ... 13 common frames omitted

I wont able to understand what exactly is the problem, as I have already added all required jar files in nar. Still I am getting this error. Please suggest me what I am doing wrong here or tell me some alternate way if you know that how I get all template object in TemplateEntity class in my onTrigger method of customProcessor.

Thanks in advance