diff --git a/pulsar-functions/run-examples.sh b/pulsar-functions/run-examples.sh index 2b4f7b2afd372..3af51780ced8c 100755 --- a/pulsar-functions/run-examples.sh +++ b/pulsar-functions/run-examples.sh @@ -17,4 +17,4 @@ # under the License. # -CLASSPATH=`pwd`/api-examples/target/pulsar-functions-api-examples.jar bin/pulsar-functions functions run --function-config conf/example.yml --sink-topic persistent://sample/standalone/ns1/test_result --source-topic persistent://sample/standalone/ns1/test_src --serde-classname org.apache.pulsar.functions.runtime.container.SimpleStringSerDe --function-classpath `pwd`/api-examples/target/pulsar-functions-api-examples.jar +bin/pulsar-functions functions run --function-config conf/example.yml --sink-topic persistent://sample/standalone/ns1/test_result --source-topic persistent://sample/standalone/ns1/test_src --serde-classname org.apache.pulsar.functions.runtime.container.SimpleStringSerDe --function-classpath `pwd`/api-examples/target/pulsar-functions-api-examples.jar diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/instance/JavaInstance.java b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/instance/JavaInstance.java index 1e47187408c1d..d88eae99bdc52 100644 --- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/instance/JavaInstance.java +++ b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/instance/JavaInstance.java @@ -59,7 +59,10 @@ public class JavaInstance { public static Object createObject(String userClassName) { Object object; try { - Class clazz = Class.forName(userClassName); + Class clazz = Class.forName( + userClassName, + true, + Thread.currentThread().getContextClassLoader()); object = clazz.newInstance(); } catch (ClassNotFoundException ex) { throw new RuntimeException(ex + " User class must be in class path.");