quarkusio/quarkus · error · IllegalArgumentException
No public method annotated with @Path
Error message
No public method annotated with @Path
What it means
After scanning the resource class's public methods by name, the builder throws this IllegalArgumentException if none of the matching methods is annotated with @Path. path(Class, String) can only build a segment from a @Path value, so a name match without the annotation is treated as 'not found'.
Source
Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java:429
}
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");
}
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)View on GitHub (pinned to e1c734241f)
Solutions
- Verify the method name string matches a public method exactly (spelling/case).
- Add @Path to the intended endpoint method on the resource class.
- Make the method public so resource.getMethods() can see it.
- Resolve the Method reflectively and call path(Method) after confirming it has @Path.
Example fix
// before
public List<Order> listAll() {...} // no @Path
builder.path(OrderResource.class, "listAll");
// after
@Path("/all")
public List<Order> listAll() {...}
builder.path(OrderResource.class, "listAll"); Defensive patterns
Strategy: validation
Validate before calling
Method target = Arrays.stream(OrderResource.class.getMethods())
.filter(m -> m.getName().equals(methodName) && m.isAnnotationPresent(Path.class))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("No public @Path method " + methodName)); Type guard
static Optional<Method> pathMethod(Class<?> c, String name) {
return Arrays.stream(c.getMethods())
.filter(m -> m.getName().equals(name) && m.isAnnotationPresent(Path.class))
.findFirst();
} Try / catch
try {
uri = builder.path(OrderResource.class, methodName).build();
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("No public method annotated with @Path")) {
throw new IllegalStateException("Check method name/visibility/@Path on " + OrderResource.class, e);
}
throw e;
} Prevention
- Verify spelling and case of the method name string
- Ensure endpoint methods are public and carry @Path
- Add a startup test that resolves every client operation name
- Grep for recently renamed/removed @Path methods after upgrades
When it happens
Trigger: Calling path(Resource.class, "list") where either no method named 'list' exists, or a method named 'list' exists but lacks @Path (e.g. it is a helper, a non-endpoint, or the @Path was removed).
Common situations: Typo in the method name string; method is private/protected so getMethods() (public only) misses it; @Path annotation dropped during refactoring or replaced with @GET-only routing; method renamed in a version upgrade.
Related errors
- Method not 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/e4feb066661eb8bb.
Report an issue: GitHub.