Nifi ExecuteGroovyScript - class already loaded in

2019-08-27 20:00发布

问题:

I get a flowfile with ExecuteGroovyScript processor with some custom code in it. and it work well :

but if I stop it and change the code in i get this error:

java.lang.UnsatisfiedLinkError: Native Library /data/nifi_flow/dec-enr/pseudo/lib/libpseudojni.so already loaded in another classloader: java.lang.UnsatisfiedLinkError: Native Library /data/nifi_flow/dec-enr/pseudo/lib/libpseudojni.so already loaded in another classloader java.lang.UnsatisfiedLinkError: Native Library /data/nifi_flow/dec-enr/pseudo/lib/libpseudojni.so already loaded in another classloader at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1907) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1122) at fr.cnam.p7.pseudo.jni.PseudoJNI.(PseudoJNI.java:6) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:68) at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:65) at java.security.AccessController.doPrivileged(Native Method) at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:65) at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:162) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117) at Scriptffffffffc26c8c01.run(Scriptffffffffc26c8c01.groovy:26) at org.apache.nifi.processors.groovyx.ExecuteGroovyScript.onTrigger(ExecuteGroovyScript.java:438) at org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27) at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1122) at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:147) at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:47) at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:128) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

After restarting nifi the processor is back to normal and work well again.

回答1:

according to the stacktrace

at java.lang.System.loadLibrary(System.java:1122) 
at fr.cnam.p7.pseudo.jni.PseudoJNI.(PseudoJNI.java:6) 
at Scriptffffffffc26c8c01.run(Scriptffffffffc26c8c01.groovy:26)

the class (PseudoJNI) you are loading from script tries to load native library

each time you change the groovy script or other parameters the new classloader used because @Grab or added classpath could be used for your script.

calling System.loadLibrary() from the second classloader triggers an error. you could try to put the library that contains PseudoJNI class into nifi/lib directory.