apache/pulsar · error · ParameterException

Cannot specify both jar and function-type

Error message

Cannot specify both jar and function-type

What it means

A function can be packaged either as a user-uploaded jar or as a built-in function type (built-in connectors/functions identified by function-type). FunctionDetailsCommand rejects a command specifying both jarFile and functionType with a ParameterException, since the runtime cannot decide between the two packaging modes.

Source

Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java:659

                }
                windowConfig.setSlidingIntervalDurationMs(slidingIntervalDurationMs);
            }

            functionConfig.setWindowConfig(windowConfig);

            if (autoAck != null) {
                functionConfig.setAutoAck(autoAck);
            }

            if (null != maxMessageRetries) {
                functionConfig.setMaxMessageRetries(maxMessageRetries);
            }
            if (null != deadLetterTopic) {
                functionConfig.setDeadLetterTopic(deadLetterTopic);
            }

            if (jarFile != null && functionType != null) {
                throw new ParameterException("Cannot specify both jar and function-type");
            }

            if (null != jarFile) {
                functionConfig.setJar(jarFile);
            }

            if (functionType != null) {
                functionConfig.setJar("builtin://" + functionType);
            } else if (functionConfig.getFunctionType() != null) {
                functionConfig.setJar("builtin://" + functionConfig.getFunctionType());
            }

            if (null != pyFile) {
                functionConfig.setPy(pyFile);
            }

            if (null != goFile) {
                functionConfig.setGo(goFile);

View on GitHub (pinned to 820761864e)

Solutions

  1. Remove --function-type if you are deploying your own jar.
  2. Remove --jar (and class name requirements) if you intend to use a built-in function type.
  3. Make wrapper scripts set exactly one of the two based on the deployment mode.

Example fix

// before
pulsar-admin functions create --tenant public --namespace default --name ex --jar my.jar --function-type org.apache.pulsar.functions.api.examples.ExclamationFunction
// after
pulsar-admin functions create --tenant public --namespace default --name ex --jar my.jar --classname org.ex.MyFn
Defensive patterns

Strategy: validation

Validate before calling

if (jarFile != null && functionType != null) {
    throw new IllegalArgumentException("Specify either --jar or --function-type, not both");
}

Try / catch

try {
    functionsCmd.run();
} catch (ParameterException e) {
    if (e.getMessage().contains("jar and function-type")) {
        System.err.println("Choose one packaging mode: uploaded jar or built-in function-type.");
    }
}

Prevention

When it happens

Trigger: Running functions create/update with both --jar (or --py/--go plus jar semantics) and --function-type / --builtin set at the same time.

Common situations: Template scripts that always pass --jar, then get extended with --function-type for built-ins; defaults baked into wrapper scripts where the jar variable is set to a non-null default.

Related errors


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