spring-projects/spring-ai · warning
No resource methods found in the provided resource objects:
Error message
No resource methods found in the provided resource objects: <resourceObjects>
What it means
This is a warning logged by AsyncStatelessMcpResourceProvider.getResourceSpecifications when annotation scanning of the configured resource objects produced zero MCP resource specifications. The library did not fail: it logs this because a provider was constructed with @McpResource-annotated expectation but no methods matched, so the server will expose no resources. It almost always indicates misconfigured resource objects or missing/wrong annotations.
Source
Thrown at mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/provider/resource/AsyncStatelessMcpResourceProvider.java:120
BiFunction<McpTransportContext, ReadResourceRequest, Mono<ReadResourceResult>> methodCallback = AsyncStatelessMcpResourceMethodCallback
.builder()
.method(mcpResourceMethod)
.bean(resourceObject)
.resource(mcpResource)
.build();
var resourceSpec = new AsyncResourceSpecification(mcpResource, methodCallback);
return resourceSpec;
})
.filter(Objects::nonNull)
.toList())
.flatMap(List::stream)
.toList();
if (resourceSpecs.isEmpty()) {
if (logger.isWarnEnabled()) {
logger.warn("No resource methods found in the provided resource objects: " + this.resourceObjects);
}
}
return resourceSpecs;
}
public List<AsyncResourceTemplateSpecification> getResourceTemplateSpecifications() {
List<AsyncResourceTemplateSpecification> resourceSpecs = this.resourceObjects.stream()
.map(resourceObject -> Stream.of(doGetClassMethods(resourceObject))
.filter(method -> method.isAnnotationPresent(McpResource.class))
.filter(McpPredicates.filterNonReactiveReturnTypeMethod())
.sorted((m1, m2) -> m1.getName().compareTo(m2.getName()))
.map(mcpResourceMethod -> {
var resourceAnnotation = doGetMcpResourceAnnotation(mcpResourceMethod);
var uri = resourceAnnotation.uri();View on GitHub (pinned to 98a7beda4f)
Solutions
- Verify each resource object has at least one public method annotated with @McpResource (with correct uri/description attributes).
- Confirm the classes passed to the provider builder are the ones actually holding the annotated methods, and that the list is non-empty.
- Check method visibility and signatures match what the annotation scanner requires (public, correct parameter types).
- If the resource provider is intentionally empty, remove it or silence the warning rather than shipping a no-op provider.
Example fix
// before
new AsyncStatelessMcpResourceProvider(List.of(new MyResources())); // MyResources has no @McpResource methods
// after
public class MyResources {
@McpResource(uri = "file:///docs/{name}", description = "Docs")
public String getDoc(String name) { return "..."; }
} Defensive patterns
Strategy: validation
Validate before calling
// Before registering the provider, assert the scan would find resources:
long resourceMethods = Arrays.stream(myResourceObject.getClass().getDeclaredMethods())
.filter(m -> m.isAnnotationPresent(McpResource.class) && Modifier.isPublic(m.getModifiers()))
.count();
if (resourceMethods == 0) throw new IllegalStateException(myResourceObject + " has no public @McpResource methods"); Prevention
- Unit-test each resource object for at least one public @McpResource method before wiring the provider.
- Always register the exact bean instances holding the annotated methods.
- Grep the codebase for @McpResource after refactors to ensure annotations survived.
- Watch startup logs for this warning in CI so empty providers fail the build.
When it happens
Trigger: Constructing AsyncStatelessMcpResourceProvider with resource objects that contain no methods annotated with @McpResource, or whose annotated methods are non-public/wrong signature so the reflection scan filters them out, or passing an empty resource objects list; the empty resourceSpecs list triggers the warn at AsyncStatelessMcpResourceProvider.java:120.
Common situations: Forgeting @McpResource on handler methods; annotating private/package-private methods; passing the wrong bean to the provider builder; Spring component scanning not picking up the resource class; a refactoring/upgrade renamed or moved the annotation so old imports no longer match.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- No resource methods found in the provided resource objects:
- No sampling methods found
- No sampling methods found
- No tool methods found in the provided tool objects: <toolObj
- No tool methods found in the provided tool objects: <toolObj
AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11).
Data as JSON: /api/errors/0c7aa42c7af0f68a.
Report an issue: GitHub.