yfathi opened a new issue #6239: Pulsar Functions  not working in LocalRunner 
(2.5.0)
URL: https://github.com/apache/pulsar/issues/6239
 
 
   **Describe the bug**
   Pulsar Function are not working with LocalRunner
   **To Reproduce**
   Steps to reproduce the behavior:
   1. Create a Function
   --------------------------------------------
   ```
   import org.apache.pulsar.functions.api.Context;
   import org.apache.pulsar.functions.api.Function;
   public class CounterFunction implements Function<String, String> {
       @Override
       public String process(String input, Context context) {
           Arrays.asList(input.split("\\s+")).forEach(word -> 
context.incrCounter(word, 1));
           return input;
       }
   }
   ```
   ---------------------------------------------
   2. Create a LocalRunner
   ---------------------------------------------
   ```
   import org.apache.pulsar.common.functions.FunctionConfig;
   import org.apache.pulsar.functions.LocalRunner;
   
   
   import java.util.Collections;
   
   public class CounterRunner {
   
       public static void main(String[] args) throws Exception {
   
           FunctionConfig functionConfig = new FunctionConfig();
           functionConfig.setName("counter");
           functionConfig.setInputs(Collections.singleton("input"));
           functionConfig.setClassName(CounterFunction.class.getName());
           functionConfig.setRuntime(FunctionConfig.Runtime.JAVA);
           functionConfig.setOutput("output");
   
           LocalRunner localRunner = 
LocalRunner.builder().functionConfig(functionConfig).build();
           localRunner.start(true);
       }
   
   ```
   3. Start a Local Pulsar Instance Or Configure Local Runner to Connect to 
your Pusar
         LocalRunner localRunner = 
LocalRunner.builder().functionConfig(functionConfig).brokerServiceUrl("pulsar://PORT:PORT").build();
   
   4. Execute : and see Error  :  
   ```
   Exception in thread "main" java.lang.NoClassDefFoundError: 
org/apache/pulsar/functions/runtime/shaded/io/netty/util/Timer
        at 
org.apache.pulsar.client.impl.ClientBuilderImpl.build(ClientBuilderImpl.java:62)
        at 
org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactory.createPulsarClient(ThreadRuntimeFactory.java:96)
        at 
org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactory.<init>(ThreadRuntimeFactory.java:67)
        at 
org.apache.pulsar.functions.LocalRunner.startThreadedMode(LocalRunner.java:405)
        at org.apache.pulsar.functions.LocalRunner.start(LocalRunner.java:319)
        at com.functions.CounterRunner.main(CounterRunner.java:24)
   Caused by: java.lang.ClassNotFoundException: 
org.apache.pulsar.functions.runtime.shaded.io.netty.util.Timer
        at 
java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
        at 
java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 6 more
   [INFO ] 2020-02-06 10:43:49.132 [Thread-0] LocalRunner - Shutting down the 
localrun runtimeSpawner ...
   
   Process finished with exit code 1
   ```
   
   **Expected behavior**
   
   Pulsar Function works and consumer input topic / produce into output topic
   
   
   **Desktop (please complete the following information):**
   - OS: Windows 
   - IDE : Intellij 2019.3
   - Java : 11
   - dependencies {
       implementation group: 'org.apache.pulsar', name: 
'pulsar-functions-local-runner', version: '2.5.0'
   }
   
   **Additional context**
   IT works in the previous version (2.4.0)
   - dependencies {
       implementation group: 'org.apache.pulsar', name: 
'pulsar-functions-local-runner', version: '2.4.0'
   }

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to