Support Questions

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

ExecuteScrip Groovy ClassNotFound Exception

avatar
Super Guru

Hi,

Im new to Nifi and Groovy. I have been trying to run a groovy script using the ExecuteScript Processor but not matter what my groovy code is I keep getting the exception "Java.Lang.NoClassDefFoundError: Couldnot Initialize class groovy.lang.groovySystem" not sure why? I have installed the groovy sdk and set the environment variable PATH accordingly. Not sure what else I have to do? Thanks for your help.

1 ACCEPTED SOLUTION

avatar
Expert Contributor

@SAMSAL 

 

NiFi will only run on java 8 or 11

 

"NiFi requires Java 8 or 11. It is recommended that you have installed one of these Java versions prior to installing NiFi via Homebrew. Homebrew is aware NiFi depends on Java but not the specific supported versions, so it may prompt to install an incompatible JDK as part of its NiFi install."

 

https://nifi.apache.org/docs/nifi-docs/html/getting-started.html#downloading-and-installing-nifi

 

View solution in original post

9 REPLIES 9

avatar
Super Guru

Anybody can help with this please? I cant progress without resolving this error which seems to be related to Nifi\groovy configuration that prevents me from running any kind of groovy script from nifi. Thanks

avatar
Expert Contributor

@SAMSAL thanks for confirmation, what java version is the NiFi JVM using?

 

You can find it multiple ways but maybe easiest is to look at:

 

Global Configuration Menu ( top right ) > Cluster > Versions tab 

 

Or if single node maybe just finding the java version windows has, assuming not multiple.

avatar
Super Guru

Im using single instance. I just ran the "java -version" command, and here is what I have:

java version "14.0.1" 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)

avatar
Expert Contributor

@SAMSAL 

 

NiFi will only run on java 8 or 11

 

"NiFi requires Java 8 or 11. It is recommended that you have installed one of these Java versions prior to installing NiFi via Homebrew. Homebrew is aware NiFi depends on Java but not the specific supported versions, so it may prompt to install an incompatible JDK as part of its NiFi install."

 

https://nifi.apache.org/docs/nifi-docs/html/getting-started.html#downloading-and-installing-nifi

 

avatar
Super Guru

OK,  will try to install the required java version. My bad, I did not think that would cause the problem. Do I have to uninstall nifi and reinstall everything or just uninstalling\reinstalling java would suffice.?

Thanks for your help

avatar
Expert Contributor

Just install the right java should be good enough.

And if you get more than one JAVA just point JAVA HOME to a proper version for NiFi

avatar
Super Guru

Thank you very much! After installing the proper java version the Groovy script started to work.

avatar
Expert Contributor

Hi @SAMSAL ,

 

Could you provide a bit more info.

What version of NiFi are you on?

Can you provide the script?

 

If you are using ExecuteScript make sure you are setting groovy as script engine and you do not need to install Groovy separately for ExecuteScript because it runs on the internal JVM using JSR-223 scripting.

 

So if you are setting Module Directory just because you think you need to set that to point to groovy, try unsetting that.

 

and can you run a simple script to test this out:

 

 

import groovy.io.FileType
def flowFile = session.get();
session.transfer(flowFile, REL_SUCCESS)

 

avatar
Super Guru

Thanks for attending to my ticket.

Im using what I think the latest nifi version 1.11.4. Running on windows 10 for testing.

I was using script similar to what is provided in (https://community.cloudera.com/t5/Community-Articles/ExecuteScript-Cookbook-part-1/ta-p/248922 )  which seems to be outdated because the scripting languages there doesnt match what I see in the latest version of Nifi. None the less when I try your script it still fails with the same error (other scripts engine like python works fine):

ExecuteScript[id=c461682d-0173-1000-f3bb-1a7ace8e772d] ExecuteScript[id=c461682d-0173-1000-f3bb-1a7ace8e772d] failed to process session due to Could not initialize class org.codehaus.groovy.classgen.Verifier; Processor Administratively Yielded for 1 sec: java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.classgen.Verifier
 

 

ExecuteSriptGroovy.JPG