quarkusio/quarkus · error · IllegalStateException

Unable to invoke ResteasyClientBuilder method: ${builderMeth

Error message

Unable to invoke ResteasyClientBuilder method: ${builderMethodName}

What it means

After locating a matching ResteasyClientBuilder method reflectively and building the argument array, the invocation of that method failed. The original reflection exception (IllegalAccessException, IllegalArgumentException, or InvocationTargetException) is attached as the cause. This indicates the method exists and arguments were supplied, but calling it failed at runtime.

Source

Thrown at extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/QuarkusRestClientBuilder.java:683

            if (builderMethod == null) {
                throw new IllegalArgumentException("ResteasyClientBuilder setter method not found: " + builderMethodName);
            }
            Object[] arguments;
            if (builderMethod.getParameterCount() > 1) {
                if (value instanceof List) {
                    arguments = ((List<?>) value).toArray();
                } else {
                    throw new IllegalArgumentException(
                            "Value must be an instance of List<> for ResteasyClientBuilder setter method: "
                                    + builderMethodName);
                }
            } else {
                arguments = new Object[] { value };
            }
            try {
                builderMethod.invoke(builderDelegate, arguments);
            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
                throw new IllegalStateException("Unable to invoke ResteasyClientBuilder method: " + builderMethodName, e);
            }
        }
        builderDelegate.property(name, value);
        return this;
    }

    private Object newInstanceOf(Class<?> clazz) {
        if (PROVIDER_FACTORY != null) {
            return PROVIDER_FACTORY.injectedInstance(clazz);
        }
        return this.getBuilderDelegate().getProviderFactory().injectedInstance(clazz);
    }

    @Override
    public RestClientBuilder register(Class<?> aClass) {
        register(newInstanceOf(aClass));
        return this;
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Inspect the getCause() of the IllegalStateException to find the real failure (type mismatch vs. thrown inside the builder)
  2. Ensure the value type matches the method parameter types exactly (use autoboxing-compatible types, e.g. Long/int)
  3. In native mode, verify the ResteasyClientBuilder methods used via resteasy.* properties are registered for reflection
  4. Remove or fix the offending resteasy.* property

Example fix

// before
builder.property("resteasy.connectionTTL", "2000"); // String, method expects long
// after
builder.property("resteasy.connectionTTL", 2000L);
Defensive patterns

Strategy: try-catch

Validate before calling

Method m = ResteasyClientBuilder.class.getMethod(methodName, paramTypes);
// verify value types are assignable to paramTypes before invoking

Type guard

static boolean argsMatch(Method m, Object[] args) {
    Class<?>[] ps = m.getParameterTypes();
    if (ps.length != args.length) return false;
    for (int i = 0; i < ps.length; i++) {
        if (args[i] != null && !ps[i].isInstance(args[i])) return false;
    }
    return true;
}

Try / catch

try {
    builder.property("resteasy." + name, value);
} catch (IllegalStateException e) {
    Throwable cause = e.getCause();
    log.error("Builder method invocation failed: " + cause, cause);
}

Prevention

When it happens

Trigger: Reflective invoke of a resteasy.* mapped builder method throws — e.g. argument types don't match the method signature (IllegalArgumentException), the method itself threw (InvocationTargetException), or access restrictions in native-image/graal reflection metadata.

Common situations: Passing wrong-typed values (String where long expected) via .property(); invocation failures wrapped inside InvocationTargetException from the RESTEasy builder; native-image builds missing reflection config for the method.

Related errors


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