quarkusio/quarkus · error · NotFoundException
Unable to find matching target resource method
Error message
Unable to find matching target resource method
What it means
ClassRoutingHandler dispatches a request to a resource method once the class has been matched. When no method template matches the remaining path, HTTP method, and content/accept types, it throws NotFoundException (404) 'Unable to find matching target resource method' after giving other routes a chance to process it.
Source
Thrown at independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/ClassRoutingHandler.java:134
if (pathParamValue == null) {
break;
}
requestContext.setPathParamValue(i + parameterOffset, pathParamValue);
}
}
private void throwNotFound(ResteasyReactiveRequestContext requestContext) {
ProvidersImpl providers = requestContext.getProviders();
ExceptionMapper<NotFoundException> exceptionMapper = providers.getExceptionMapper(NotFoundException.class);
if (exceptionMapper == null || servletPresent) {
if (requestContext.resumeExternalProcessing()) {
return;
}
}
// the exception mapper needs access to request scoped beans, so make sure we have the context
requestContext.requireCDIRequestScope();
throw new NotFoundException("Unable to find matching target resource method");
}
private String getRemaining(ResteasyReactiveRequestContext requestContext) {
return requestContext.getRemaining().isEmpty() ? "/" : requestContext.getRemaining();
}
public Map<String, RequestMapper<RuntimeResource>> getMappers() {
return mappers;
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Verify the exact request path, verb and Content-Type against the resource's @Path/@GET-@POST/@Consumes/@Produces annotations.
- Add the missing @Consumes (e.g. application/json) or @Produces so the method matches the request's headers.
- Check for trailing slash or context-root mismatch; compare with Dev UI / swagger-ui route listing.
- Ensure the application was rebuilt/restarted after adding or changing resource methods.
- Add a @Produces/@Consumes wildcard (e.g. @Consumes(MediaType.APPLICATION_JSON) on client side) or a catch-all method to see routing reach the class.
Example fix
// before
@POST @Path("/items")
public Item create(Item i) { ... } // client sends no Content-Type
// after (client)
curl -X POST -H 'Content-Type: application/json' -d '{...}' /items Defensive patterns
Strategy: try-catch
Validate before calling
// client-side pre-check that route shape matches
URI u = URI.create(baseUri + "/items/42");
if (!u.getPath().matches(".*/items/[^/]+$")) throw new IllegalArgumentException("Path does not match /items/{id}"); Try / catch
try {
return client.target(url).request().get();
} catch (NotFoundException e) {
if (e.getMessage() != null && e.getMessage().contains("Unable to find matching target resource method")) {
log.errorf("Route mismatch: check path/verb/Content-Type for %s %s", method, url);
}
throw e;
} Prevention
- Cross-check @Path/@GET-@POST/@Consumes/@Produces against client calls.
- Use swagger-ui or the Dev UI route list to verify registered endpoints.
- Send explicit Content-Type matching @Consumes.
- Rebuild/reload after adding methods (dev mode live reload can miss annotation-only changes occasionally).
When it happens
Trigger: Path matches the resource class but no method matches: wrong sub-path, wrong HTTP verb, missing/incorrect @Consumes or @Produces for the request's Content-Type/Accept, or a trailing-slash/encoding difference.
Common situations: Typos in @Path; calling POST on a GET-only endpoint; sending Content-Type the method's @Consumes doesn't include (415 disguised as 404 in class-level routing); missing @Path on the method; case-sensitive path segments; application not reloaded after adding the method.
Related errors
- ${exposedEndpoint} is declared by :${endpointConfigs}
- Resource locator method returned object that was not a resou
- Failed to locate ${targetCoords.toCompactCoords()} among the
- Providing multiple BuiltInReaderOverrideBuildItem for the sa
- @Compressed and @Uncompressed cannot be both declared on res
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/6cd0aa02a4006cfd.
Report an issue: GitHub.