Colin Dean created NIFI-5579:
--------------------------------
Summary: Allow ExecuteGroovyScript to take a SQL property that is
a DBCPConnectionPoolLookup
Key: NIFI-5579
URL: https://issues.apache.org/jira/browse/NIFI-5579
Project: Apache NiFi
Issue Type: Wish
Components: Core Framework
Affects Versions: 1.7.1, 1.7.0
Environment: Any
Reporter: Colin Dean
I would like to reference a {{DBCPConnectionPoolLookup}} controller service
from within an {{ExecuteGroovyScript}} processor. If I create a property
{{SQL.lookup}} and set its value to an existing {{DBCPConnectionPoolLookup}}
controller service, when I start the processor, it fails immediately because
the creation of the "connection" by the {{DBCPConnectionPoolLookup}} controller
service fails because it was not passed the expected {{database.name}}
attribute.
{code}
2018-09-07 16:04:28,229 ERROR [Timer-Driven Process Thread-227]
o.a.n.p.groovyx.ExecuteGroovyScript
ExecuteGroovyScript[id=684100f5-78cf-35f9-28db-0fa4d1d30c13]
org.apache.nifi.processor.exception.ProcessException: Attributes must contain
an attribute name 'database.name':
org.apache.nifi.processor.exception.ProcessException: Attributes must contain
an attribute name 'database.name'
org.apache.nifi.processor.exception.ProcessException: Attributes must contain
an attribute name 'database.name'
at
org.apache.nifi.dbcp.DBCPConnectionPoolLookup.getConnection(DBCPConnectionPoolLookup.java:124)
at sun.reflect.GeneratedMethodAccessor507.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.apache.nifi.controller.service.StandardControllerServiceInvocationHandler.invoke(StandardControllerServiceInvocationHandler.java:84)
at com.sun.proxy.$Proxy150.getConnection(Unknown Source)
at
org.apache.nifi.processors.groovyx.ExecuteGroovyScript.onInitSQL(ExecuteGroovyScript.java:339)
at
org.apache.nifi.processors.groovyx.ExecuteGroovyScript.onTrigger(ExecuteGroovyScript.java:439)
at
org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
at
org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1165)
at
org.apache.nifi.controller.tasks.ConnectableTask.invoke(ConnectableTask.java:203)
at
org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:117)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
2018-09-07 16:04:28,232 ERROR [Timer-Driven Process Thread-227]
o.a.n.p.groovyx.ExecuteGroovyScript
ExecuteGroovyScript[id=684100f5-78cf-35f9-28db-0fa4d1d30c13]
ExecuteGroovyScript[id=684100f5-78cf-35f9-28db-0fa4d1d30c13] failed to process
session due to java.lang.ClassCastException: com.sun.proxy.$Proxy150 cannot be
cast to org.apache.nifi.processors.groovyx.sql.OSql; Processor Administratively
Yielded for 1 sec: java.lang.ClassCastException: com.sun.proxy.$Proxy150 cannot
be cast to org.apache.nifi.processors.groovyx.sql.OSql
java.lang.ClassCastException: com.sun.proxy.$Proxy150 cannot be cast to
org.apache.nifi.processors.groovyx.sql.OSql
at
org.apache.nifi.processors.groovyx.ExecuteGroovyScript.onFinitSQL(ExecuteGroovyScript.java:371)
at
org.apache.nifi.processors.groovyx.ExecuteGroovyScript.onTrigger(ExecuteGroovyScript.java:464)
at
org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
at
org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1165)
at
org.apache.nifi.controller.tasks.ConnectableTask.invoke(ConnectableTask.java:203)
at
org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:117)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
{code}
This is because of this
[here|https://github.com/apache/nifi/blob/fc1461298a0a137d0fae3cd3b494fc6dec25070a/nifi-nar-bundles/nifi-groovyx-bundle/nifi-groovyx-processors/src/main/java/org/apache/nifi/processors/groovyx/ExecuteGroovyScript.java#L339]:
{code:java}
DBCPService s = (DBCPService) e.getValue();
OSql sql = new OSql(s.getConnection(Collections.emptyMap()));
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)