quarkusio/quarkus · error · IllegalArgumentException

method is null

Error message

method is null

What it means

UriBuilderImpl.path(Class, String) throws this IllegalArgumentException when the method-name String parameter is null. The builder matches methods on the resource class by name via equals(), and a null name can never match, so it fails fast with a clear message.

Source

Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java:417

    @SuppressWarnings("unchecked")
    public UriBuilder path(Class resource) throws IllegalArgumentException {
        if (resource == null)
            throw new IllegalArgumentException("path is null");
        Path ann = (Path) resource.getAnnotation(Path.class);
        if (ann != null) {
            String[] segments = new String[] { ann.value() };
            path = paths(true, path, segments);
        } else {
            throw new IllegalArgumentException("class must be annotated with @Path");
        }
        return this;
    }

    public UriBuilder path(Class resource, String method) throws IllegalArgumentException {
        if (resource == null)
            throw new IllegalArgumentException("resource is null");
        if (method == null)
            throw new IllegalArgumentException("method is null");
        Method theMethod = null;
        for (Method m : resource.getMethods()) {
            if (m.getName().equals(method)) {
                if (theMethod != null && m.isAnnotationPresent(Path.class)) {
                    throw new IllegalArgumentException("Two methods with the same path " + method);
                }
                if (m.isAnnotationPresent(Path.class))
                    theMethod = m;
            }
        }
        if (theMethod == null)
            throw new IllegalArgumentException("No public method annotated with @Path " + resource.getName() + " " + method);
        return path(theMethod);
    }

    public UriBuilder path(Method method) throws IllegalArgumentException {
        if (method == null) {
            throw new IllegalArgumentException("method is null");

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pass a non-null method name matching a public method on the resource class.
  2. Validate the source of the name (annotation value, config, map key) before the call.
  3. Guard with Objects.requireNonNull(method, "method name required").
  4. If you have the reflective Method already, use path(Method) instead.

Example fix

// before
builder.path(OrderResource.class, methodName); // methodName null
// after
if (methodName == null) throw new IllegalStateException("operation name not resolved");
builder.path(OrderResource.class, methodName);
Defensive patterns

Strategy: validation

Validate before calling

if (methodName == null || methodName.isBlank()) {
    throw new IllegalArgumentException("method name required for UriBuilder.path(Class, String)");
}

Type guard

static boolean hasMethodName(Class<?> c, String name) {
    return c != null && name != null && java.util.Arrays.stream(c.getMethods())
        .anyMatch(m -> m.getName().equals(name));
}

Try / catch

try {
    builder.path(resourceClass, methodName);
} catch (IllegalArgumentException e) {
    if (e.getMessage().equals("method is null")) {
        throw new IllegalStateException("Method name not resolved for " + resourceClass, e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling resource.path(MyResource.class, null), often because the method name comes from a variable, annotation value, or map entry that is unset/null.

Common situations: Reflection-driven client/link builders reading a method name from config or metadata that is missing; frameworks generating calls where the operation name was not resolved.

Related errors


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