Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-5579

Allow ExecuteGroovyScript to take a SQL property that is a DBCPConnectionPoolLookup

    XMLWordPrintableJSON

    Details

    • Type: Wish
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.7.0, 1.7.1
    • Fix Version/s: None
    • Component/s: Core Framework
    • Labels:
    • Environment:
      Any

      Description

      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.

      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)
      

      This is because of this here:

      DBCPService s = (DBCPService) e.getValue();
      OSql sql = new OSql(s.getConnection(Collections.emptyMap()));
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              colindean Colin Dean
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: