quarkusio/quarkus · error · IllegalArgumentException
Method not annotated with @Path
Error message
Method not annotated with @Path
What it means
UriBuilderImpl.path(Method) builds the segment from the method's @Path annotation value; if the reflective Method has no @Path annotation the builder cannot derive a path and throws this IllegalArgumentException. Note the null-Method case has its own distinct message ('method is null'), so this one means a real Method was supplied but is not an annotated endpoint.
Source
Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java:441
}
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");
}
Path ann = method.getAnnotation(Path.class);
if (ann != null) {
path = paths(encode, path, ann.value());
} else {
throw new IllegalArgumentException("Method not annotated with @Path");
}
return this;
}
public UriBuilder replaceMatrix(String matrix) throws IllegalArgumentException {
if (matrix == null)
matrix = "";
if (!matrix.startsWith(";"))
matrix = ";" + matrix;
matrix = Encode.encodePath(matrix);
if (path == null) {
path = matrix;
} else {
int start = path.lastIndexOf('/');
if (start < 0)
start = 0;
int matrixIndex = path.indexOf(';', start);
if (matrixIndex > -1)View on GitHub (pinned to e1c734241f)
Solutions
- Only pass methods annotated with @Path to path(Method).
- Add @Path to the method if it is genuinely an endpoint.
- Use path(Class) for the class-level segment and skip methods without @Path.
- Pre-check method.isAnnotationPresent(Path.class) before calling.
Example fix
// before
Method m = OrderResource.class.getMethod("toString");
builder.path(m); // throws
// after
Method m = OrderResource.class.getMethod("get"); // has @Path
builder.path(m); Defensive patterns
Strategy: validation
Validate before calling
if (method != null && !method.isAnnotationPresent(jakarta.ws.rs.Path.class)) {
throw new IllegalArgumentException(method + " is not a @Path-annotated endpoint");
} Type guard
static boolean isPathAnnotated(Method m) {
return m != null && m.isAnnotationPresent(jakarta.ws.rs.Path.class);
} Try / catch
try {
builder.path(method);
} catch (IllegalArgumentException e) {
if (e.getMessage().equals("Method not annotated with @Path")) {
throw new IllegalStateException("Non-endpoint method passed to path(): " + method, e);
}
throw e;
} Prevention
- Filter candidate methods by isAnnotationPresent(Path.class) before calling
- Do not pass helpers/getters to path(Method)
- Remember class-level-only @Path resources still need method-level @Path for path(Method)
- Add annotation-presence unit tests for client method discovery
When it happens
Trigger: Passing a Method that is a plain helper, getter, or lifecycle method (no @Path) — e.g. from path(Resource.class, "helperName") resolution or a random reflective method.
Common situations: Mistakenly treating non-endpoint methods as endpoints in client/link generation; the @Path annotation moved to the class only, leaving methods unannotated; annotation processing or Lombok-related setups where the annotation is not visible on the resolved Method.
Related errors
- No public method annotated with @Path
- class must be annotated with @Path
- resource is null
- method is null
- Two methods with the same path
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/da06e12480c890e8.
Report an issue: GitHub.