Skip to main content
SAMSAL
Platinum ⭐️⭐️⭐️
August 3, 2020
Solved

ExecuteScrip Groovy ClassNotFound Exception

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.

DigitalPlumber
Gold ⭐️
August 6, 2020

@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

 

9 replies

SAMSAL
SAMSALAuthor
Platinum ⭐️⭐️⭐️
August 6, 2020

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

Translate
DigitalPlumber
Gold ⭐️
Gold ⭐️
August 6, 2020

@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.

Translate
SAMSAL
SAMSALAuthor
Platinum ⭐️⭐️⭐️
August 7, 2020

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

Translate
DigitalPlumber
Gold ⭐️
Gold ⭐️
August 6, 2020

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)

 

Translate
SAMSAL
SAMSALAuthor
Platinum ⭐️⭐️⭐️
August 6, 2020

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

Translate