{"record":{"id":"500eca86323cbd4c","repo":"apache/pulsar","slug":"timestamp-extractor-class-s-must-be-in-class-path","errorCode":null,"errorMessage":"Timestamp extractor class %s must be in class path","messagePattern":"Timestamp extractor class (.+?) must be in class path","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/windowing/WindowFunctionExecutor.java","lineNumber":137,"sourceCode":"\n        EvictionPolicy<Record<T>, ?> evictionPolicy = getEvictionPolicy(windowConfig);\n        TriggerPolicy<Record<T>, ?> triggerPolicy = getTriggerPolicy(windowConfig, manager,\n                evictionPolicy, context);\n        manager.setEvictionPolicy(evictionPolicy);\n        manager.setTriggerPolicy(triggerPolicy);\n\n        return manager;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private TimestampExtractor<T> getTimeStampExtractor(WindowConfig windowConfig) {\n\n        Class<?> theCls;\n        try {\n            theCls = Class.forName(windowConfig.getTimestampExtractorClassName(),\n                    true, Thread.currentThread().getContextClassLoader());\n        } catch (ClassNotFoundException | NoClassDefFoundError cnfe) {\n            throw new RuntimeException(\n                    String.format(\"Timestamp extractor class %s must be in class path\",\n                            windowConfig.getTimestampExtractorClassName()), cnfe);\n        }\n\n        Object result;\n        try {\n            Constructor<?> constructor = theCls.getDeclaredConstructor();\n            constructor.setAccessible(true);\n            result = constructor.newInstance();\n        } catch (InstantiationException ie) {\n            throw new RuntimeException(\"User class must be concrete\", ie);\n        } catch (NoSuchMethodException e) {\n            throw new RuntimeException(\"User class doesn't have such method\", e);\n        } catch (IllegalAccessException e) {\n            throw new RuntimeException(\"User class must have a no-arg constructor\", e);\n        } catch (InvocationTargetException e) {\n            throw new RuntimeException(\"User class constructor throws exception\", e);\n        }","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/windowing/WindowFunctionExecutor.java#L119-L155","documentation":"When a custom timestampExtractorClassName is configured, getTimeStampExtractor loads it with Class.forName using the thread context classloader. If the class (or something it references) cannot be found or linked, the executor wraps the ClassNotFoundException/NoClassDefFoundError in a RuntimeException naming the class. This means the user's timestamp extractor jar is not shipped with the function or the class name is wrong.","triggerScenarios":"WindowConfig.timestampExtractorClassName set to a class not in the function's fat jar / nar; typo in fully-qualified name; NoClassDefFoundError from a missing transitive dependency of the extractor.","commonSituations":"Deploying a function without uploading the extractor class's jar; package rename after refactor; class present in broker but not in function instance classpath.","solutions":["Bundle the timestamp extractor class (and its dependencies) in the function jar and redeploy","Correct the fully-qualified class name in WindowConfig.timestampExtractorClassName","Check function instance logs for the caused-by ClassNotFoundException to see the missing class name","Ensure the class is on the function instance classpath, not only the broker's"],"exampleFix":"// before\n\"timestampExtractorClassName\": \"com.example.TimeStampExtractor\"  // typo, class not uploaded\n// after\n\"timestampExtractorClassName\": \"com.example.MyTimestampExtractor\"  // included in function uber-jar","handlingStrategy":"validation","validationCode":"try {\n    Class.forName(className, true, Thread.currentThread().getContextClassLoader());\n} catch (ClassNotFoundException e) {\n    throw new IllegalStateException(\"extractor class not in function jar: \" + className);\n}","typeGuard":null,"tryCatchPattern":"try {\n    executor.initialize();\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof ClassNotFoundException || e.getCause() instanceof NoClassDefFoundError) {\n        throw new IllegalStateException(\"bundle the extractor class and its dependencies in the function jar\", e);\n    }\n    throw e;\n}","preventionTips":["Build the function as an uber-jar containing the extractor and its transitive deps","Verify the fully-qualified class name with `jar tf app.jar | grep TimestampExtractor`","Test extractor loading locally with the same classloader setup"],"tags":["pulsar-functions","windowing","classpath","classnotfound"],"backgroundTag":"class-not-found","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}