apache/pulsar · error · IllegalArgumentException

Function class name is not provided.

Error message

Function class name is not provided.

What it means

The Java function validation (doJavaChecks) could not determine the function's implementing class. If className is not set on the FunctionConfig, the validator tries to read a FunctionDefinition from the NAR package archive; if neither the config nor the NAR metadata provides a class name, IllegalArgumentException is thrown.

Source

Thrown at pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionConfigUtils.java:637

        if (windowConfig != null) {
            WindowConfigUtils.inferMissingArguments(windowConfig);
            functionConfig.setAutoAck(false);
        }
    }

    public static ExtractedFunctionDetails doJavaChecks(FunctionConfig functionConfig,
                                                        ValidatableFunctionPackage validatableFunctionPackage) {

        String functionClassName = StringUtils.trimToNull(functionConfig.getClassName());
        TypeDefinition functionClass;
        try {
            // if class name in function config is not set, this should be a built-in function
            // thus we should try to find its class name in the NAR service definition
            if (functionClassName == null) {
                FunctionDefinition functionDefinition =
                        validatableFunctionPackage.getFunctionMetaData(FunctionDefinition.class);
                if (functionDefinition == null) {
                    throw new IllegalArgumentException("Function class name is not provided.");
                }
                functionClassName = functionDefinition.getFunctionClass();
                if (functionClassName == null) {
                    throw new IllegalArgumentException("Function class name is not provided.");
                }
            }
            functionClass = validatableFunctionPackage.resolveType(functionClassName);

            if (!functionClass.asErasure().isAssignableTo(org.apache.pulsar.functions.api.Function.class)
                    && !functionClass.asErasure().isAssignableTo(java.util.function.Function.class)
                    && !functionClass.asErasure()
                    .isAssignableTo(org.apache.pulsar.functions.api.WindowFunction.class)) {
                throw new IllegalArgumentException(
                        String.format("Function class %s does not implement the correct interface",
                                functionClassName));
            }
        } catch (TypePool.Resolution.NoSuchTypeException e) {
            throw new IllegalArgumentException(

View on GitHub (pinned to 820761864e)

Solutions

  1. Set className in the FunctionConfig to the fully qualified function class
  2. If using a NAR, ensure it contains a valid function definition service file (FunctionDefinition metadata)
  3. Rebuild/repackage the function archive so the class is discoverable

Example fix

// before
FunctionConfig config = new FunctionConfig();
config.setRuntime(FunctionConfig.Runtime.JAVA);
// after
config.setClassName("org.example.MyFunction");
Defensive patterns

Strategy: validation

Validate before calling

if (config.getClassName() == null && !isNarPackage(functionPackage)) { throw new IllegalArgumentException("Java functions need className set or a NAR package with FunctionDefinition"); }

Type guard

boolean hasClassName(FunctionConfig c) { return c.getClassName() != null && !c.getClassName().isEmpty(); }

Try / catch

try { FunctionConfigUtils.validateJavaFunction(...); } catch (IllegalArgumentException e) { if (e.getMessage().contains("class name")) { /* prompt user for className */ } }

Prevention

When it happens

Trigger: Submitting a Java function with FunctionConfig.className unset whose package is not a valid NAR containing a FunctionDefinition (e.g. a plain JAR), or a NAR whose ServiceLoader metadata file is missing/empty.

Common situations: Building a function JAR instead of a NAR without setting className; malformed NAR missing META-INF/services/pulsar-function-definition; typo leaving className null in the YAML/JSON config.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/03145dc265c04976. Report an issue: GitHub.