[ 
https://issues.apache.org/jira/browse/NIFI-1622?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15191484#comment-15191484
 ] 

Oleg Zhurakousky commented on NIFI-1622:
----------------------------------------

Just had a quick chat with Mark. For most cases setting Thread context CL is 
not required since all classes that are yet to be loaded are going to be loaded 
by the CL of the class that loads them and in this case everything derives from 
the instance of the processor that is already loaded by the NAR CL.
However, since we are dealing a lot with third-party libraries we have no 
control about the techniques they are using and one case in particular where 
this problem manifested itself is Kafka which has code that explicitly loads 
something using Thread context CL (see below):
{code}
return Class.forName(trimmed, true, Utils.getContextOrKafkaClassLoader());
{code}
So while it may be unnecessary for a lot of cases it is absolutely required for 
some and since resetting it is harmless I am all +1 for the patch that is about 
to be attached by Mark.


> Not using appropriate NAR class loader when calling Processor Lifecycle 
> methods
> -------------------------------------------------------------------------------
>
>                 Key: NIFI-1622
>                 URL: https://issues.apache.org/jira/browse/NIFI-1622
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 0.6.0
>            Reporter: Mark Payne
>            Assignee: Mark Payne
>             Fix For: 0.6.0
>
>         Attachments: 
> 0001-NIFI-1622-Ensure-that-the-Nar-Context-Class-Loader-i.patch
>
>
> Since NIFI-1464 was merged to master, I have seen problems starting the 
> PutKafka processor. It appears that the NAR ClassLoader was not being 
> properly applied, per the stack trace:
> 2016-03-11 14:22:53,967 ERROR [pool-25-thread-5] 
> o.a.n.controller.StandardProcessorNode Failed to invoke @OnScheduled method 
> due to java.lang.RuntimeException: Failed while executing one of processor's 
> lifecycle tasks (OnScheduled or OnUnscheduled).
> java.lang.RuntimeException: Failed while executing one of processor's 
> lifecycle tasks (OnScheduled or OnUnscheduled).
>         at 
> org.apache.nifi.controller.StandardProcessorNode.invokeTaskAsCancelableFuture(StandardProcessorNode.java:1398)
>  ~[nifi-framework-core-0.6.0-SNAPSHOT.jar:0.6.0-SNAPSHOT]
>         at 
> org.apache.nifi.controller.StandardProcessorNode.access$100(StandardProcessorNode.java:91)
>  ~[nifi-framework-core-0.6.0-SNAPSHOT.jar:0.6.0-SNAPSHOT]
>         at 
> org.apache.nifi.controller.StandardProcessorNode$1.run(StandardProcessorNode.java:1246)
>  ~[nifi-framework-core-0.6.0-SNAPSHOT.jar:0.6.0-SNAPSHOT]
>         at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
> [na:1.8.0_60]
>         at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
> [na:1.8.0_60]
>         at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
>  [na:1.8.0_60]
>         at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
>  [na:1.8.0_60]
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>  [na:1.8.0_60]
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>  [na:1.8.0_60]
>         at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]
> Caused by: java.util.concurrent.ExecutionException: 
> java.lang.reflect.InvocationTargetException
>         at java.util.concurrent.FutureTask.report(FutureTask.java:122) 
> [na:1.8.0_60]
>         at java.util.concurrent.FutureTask.get(FutureTask.java:206) 
> [na:1.8.0_60]
>         at 
> org.apache.nifi.controller.StandardProcessorNode.invokeTaskAsCancelableFuture(StandardProcessorNode.java:1383)
>  ~[nifi-framework-core-0.6.0-SNAPSHOT.jar:0.6.0-SNAPSHOT]
>         ... 9 common frames omitted
> Caused by: java.lang.reflect.InvocationTargetException: null
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
> ~[na:1.8.0_60]
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
> ~[na:1.8.0_60]
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  ~[na:1.8.0_60]
>         at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60]
>         at 
> org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:137)
>  ~[nifi-framework-core-0.6.0-SNAPSHOT.jar:0.6.0-SNAPSHOT]
>         at 
> org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:125)
>  ~[nifi-framework-core-0.6.0-SNAPSHOT.jar:0.6.0-SNAPSHOT]
>         at 
> org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:70)
>  ~[nifi-framework-core-0.6.0-SNAPSHOT.jar:0.6.0-SNAPSHOT]
>         at 
> org.apache.nifi.controller.StandardProcessorNode$1$1.call(StandardProcessorNode.java:1250)
>  ~[nifi-framework-core-0.6.0-SNAPSHOT.jar:0.6.0-SNAPSHOT]
>         at 
> org.apache.nifi.controller.StandardProcessorNode$1$1.call(StandardProcessorNode.java:1246)
>  ~[nifi-framework-core-0.6.0-SNAPSHOT.jar:0.6.0-SNAPSHOT]
>         ... 6 common frames omitted
> Caused by: java.lang.ExceptionInInitializerError: null
>         at 
> org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:194)
>  ~[na:na]
>         at 
> org.apache.nifi.processors.kafka.PutKafka.createProducer(PutKafka.java:323) 
> ~[na:na]
>         ... 15 common frames omitted
> Caused by: org.apache.kafka.common.config.ConfigException: Invalid value 
> org.apache.kafka.clients.producer.internals.DefaultPartitioner for 
> configuration partitioner.class: Class 
> org.apache.kafka.clients.producer.internals.DefaultPartitioner could not be 
> found.
>         at 
> org.apache.kafka.common.config.ConfigDef.parseType(ConfigDef.java:255) 
> ~[na:na]
>         at org.apache.kafka.common.config.ConfigDef.define(ConfigDef.java:78) 
> ~[na:na]
>         at org.apache.kafka.common.config.ConfigDef.define(ConfigDef.java:94) 
> ~[na:na]
>         at 
> org.apache.kafka.clients.producer.ProducerConfig.<clinit>(ProducerConfig.java:206)
>  ~[na:na]
>         ... 17 common frames omitted



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to