quarkusio/quarkus · error · IllegalStateException

Global variable method declared on " + method.declaringClass

Error message

Global variable method declared on " + method.declaringClass().name() + " must not accept any parameter: " + method

What it means

IllegalStateException from TemplateGlobalGenerator.validate(MethodInfo): the @TemplateGlobal method declares parameters. Global variable accessors are invoked with no arguments, so any parameter list is rejected; the method signature appears in the message.

Source

Thrown at independent-projects/qute/generator/src/main/java/io/quarkus/qute/generator/TemplateGlobalGenerator.java:172

        return generatedClassName;
    }

    public Set<String> getGeneratedTypes() {
        return generatedTypes;
    }

    public static void validate(MethodInfo method) {
        if (!Modifier.isStatic(method.flags())) {
            throw new IllegalStateException(
                    "Global variable method declared on " + method.declaringClass().name() + " must be static: "
                            + method);
        }
        if (method.returnType().kind() == Kind.VOID) {
            throw new IllegalStateException("Global variable method declared on " + method.declaringClass().name()
                    + " must not return void: " + method);
        }
        if (!method.parameterTypes().isEmpty()) {
            throw new IllegalStateException("Global variable method declared on " + method.declaringClass().name()
                    + " must not accept any parameter: " + method);
        }
        if (Modifier.isPrivate(method.flags())) {
            throw new IllegalStateException("Global variable method declared on " + method.declaringClass().name()
                    + " must not be private: " + method);
        }
    }

    public static void validate(FieldInfo field) {
        if (!Modifier.isStatic(field.flags())) {
            throw new IllegalStateException(
                    "Global variable field declared on " + field.declaringClass().name() + "  must be static: " + field);
        }
        if (Modifier.isPrivate(field.flags())) {
            throw new IllegalStateException("Global variable field declared on " + field.declaringClass().name()
                    + " must not be private: " + field);
        }
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Remove all parameters from the @TemplateGlobal method
  2. If parameters are needed, use a value resolver or an EvalContext-based approach instead
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at independent-projects/qute/generator/src/main/java/io/quarkus/qute/generator/TemplateGlobalGenerator.java:172 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/f0df0936f98c91e0. Report an issue: GitHub.