无法在Nifi中解析类groovy.yaml.YamlSlurper

bbmckpt7  于 4个月前  发布在  其他
关注(0)|答案(1)|浏览(45)

使用Nifi1.23.2时,我无法在ExecuteScript处理器(Groovy3.0.17)或ExecuteGroovyScript处理器(Groovy3.0.18)中解析YamlSlurper类。

import groovy.yaml.YamlSlurper
return

字符串
单击“验证属性”(Verify Properties)后,我得到以下信息:

Perform Validation
Component is invalid: 'GroovyScript' is invalid because org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script53405bee.groovy: 1: unable to resolve class groovy.yaml.YamlSlurper @ line 1, column 392. che.nifi.logging.ComponentLog;import gro ^ org.codehaus.groovy.syntax.SyntaxException: unable to resolve class groovy.yaml.YamlSlurper @ line 1, column 392. at
 org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:262) at
 org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1424) at
 org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:262) at
 org.codehaus.groovy.control.CompilationUnit.lambda$new$16(CompilationUnit.java:739) at
 org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:902) at
 org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:628) at
 groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:389) at
 groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:332) at
 org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163) at
 org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154) at
 groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:330) at
 groovy.lang.GroovyShell.parseClass(GroovyShell.java:526) at
 groovy.lang.GroovyShell.parse(GroovyShell.java:538) at
 groovy.lang.GroovyShell.parse(GroovyShell.java:570) at
 org.apache.nifi.processors.groovyx.ExecuteGroovyScript.getGroovyScript(ExecuteGroovyScript.java:338) at
 org.apache.nifi.processors.groovyx.ExecuteGroovyScript.customValidate(ExecuteGroovyScript.java:222) at
 org.apache.nifi.components.AbstractConfigurableComponent.validate(AbstractConfigurableComponent.java:130) at
 org.apache.nifi.controller.AbstractComponentNode.computeValidationErrors(AbstractComponentNode.java:780) at
 org.apache.nifi.controller.StandardProcessorNode.computeValidationErrors(StandardProcessorNode.java:1141) at
 org.apache.nifi.controller.AbstractComponentNode.performValidation(AbstractComponentNode.java:735) at
 org.apache.nifi.controller.AbstractComponentNode.verifyConfig(AbstractComponentNode.java:392) at
 org.apache.nifi.controller.StandardProcessorNode.verifyConfiguration(StandardProcessorNode.java:1071) at
 org.apache.nifi.web.dao.impl.StandardProcessorDAO.verifyProcessorConfiguration(StandardProcessorDAO.java:488) at
 org.apache.nifi.web.dao.impl.StandardProcessorDAO$$FastClassBySpringCGLIB$$779e089b.invoke(<generated>) at
 org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at
 org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) at
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at
 org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at
 org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) at
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at
 org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at
 org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) at
 org.apache.nifi.web.dao.impl.StandardProcessorDAO$$EnhancerBySpringCGLIB$$4feca1d.verifyProcessorConfiguration(<generated>) at
 org.apache.nifi.web.StandardNiFiServiceFacade.performProcessorConfigVerification(StandardNiFiServiceFacade.java:843) at
 org.apache.nifi.web.StandardNiFiServiceFacade$$FastClassBySpringCGLIB$$358780e0.invoke(<generated>) at
 org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at
 org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) at
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at
 org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at
 org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) at
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at
 org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at
 org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) at
 org.apache.nifi.web.StandardNiFiServiceFacade$$EnhancerBySpringCGLIB$$245ce634.performProcessorConfigVerification(<generated>) at
 org.apache.nifi.web.api.ProcessorResource.lambda$performAsyncConfigVerification$27(ProcessorResource.java:1097) at
 org.apache.nifi.web.api.concurrent.AsyncRequestManager$2.run(AsyncRequestManager.java:117) at
 java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at
 java.base/java.util.concurrent.FutureTask.run(Unknown Source) at
 java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at
 java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at
 java.base/java.lang.Thread.run(Unknown Source) 1 error


我也试

def YamlSlurper = groovy.yaml.YamlSlurper
def y = new YamlSlurper()


同样的结果。
错误?还是我遗漏了什么?有什么解决方法吗?

vbopmzt1

vbopmzt11#

groovy-yaml模块是Groovy 3中的一个 * 可选 * 模块。如果我查看Nifi安装的lib\nifi-groovyx-nar-1.23.2.nar文件,我确实可以看到相关的jar文件丢失了(我假设他们只捆绑了groovy-all jar文件)。
您可以使用@Grab('org.codehaus.groovy:groovy-yaml:3.0.18')注解您的导入,或者如果您在本地有相关的jar,您可以将处理器的“Additional classpath”属性指向jar(groovy-yaml和依赖项)。
groovy-yaml模块包含在Groovy 4+中,所以在未来的Nifi版本中可能不需要这个额外的需求。

相关问题