alibaba/arthas · error · IllegalArgumentException

Couldn't find rpcmethod: {}

Error message

Couldn't find rpcmethod: {}

What it means

GrpcWebRequestHandler.getRpcMethod() throws IllegalArgumentException when no method on the resolved gRPC stub class matches the requested rpcMethodName. The proxy iterates the stub's public methods via reflection; a miss means the method name derived from the URL doesn't correspond to any generated RPC method.

Source

Thrown at labs/arthas-grpc-web-proxy/src/main/java/com/taobao/arthas/grpcweb/proxy/GrpcWebRequestHandler.java:152

        try {
            Method m = cls.getDeclaredMethod(stubName, io.grpc.Channel.class);
            return (io.grpc.stub.AbstractStub) m.invoke(null, ch);
        } catch (Exception e) {
            logger.warn("Error when fetching " + stubName + " for: " + cls.getName());
            throw new IllegalArgumentException(e);
        }
    }

    /**
     * Find the matching method in the stub class.
     */
    private Method getRpcMethod(Object stub, String rpcMethodName) {
        for (Method m : stub.getClass().getMethods()) {
            if (m.getName().equals(rpcMethodName)) {
                return m;
            }
        }
        throw new IllegalArgumentException("Couldn't find rpcmethod: " + rpcMethodName);
    }

    private static class GrpcCallResponseReceiver<Object> implements StreamObserver {
        private final SendGrpcWebResponse sendResponse;
        private final CountDownLatch latch;

        private final ManagedChannel channel;

        GrpcCallResponseReceiver(SendGrpcWebResponse s, CountDownLatch c, ManagedChannel channel) {
            sendResponse = s;
            latch = c;
            this.channel = channel;
        }

        @Override
        public void onNext(java.lang.Object resp) {
            // TODO verify that the resp object is of Class instance returnedCls.
            byte[] outB = ((com.google.protobuf.GeneratedMessageV3) resp).toByteArray();

View on GitHub (pinned to 21cf2e9ba5)

Solutions

  1. Verify the method name in the URL matches a real method on the generated *Grpc stub class.
  2. Regenerate the gRPC stubs from the current .proto and redeploy both client and server.
  3. Check for first-character-casing issues: the proxy lowercases the first char of the method name; ensure the actual stub method name matches that convention.
  4. Confirm the class segment of the URL resolves to the correct service (not a similarly-named class).

Example fix

// before: method renamed from getData to fetchData in proto
// URL: /MyService/getData  -> throws 'Couldn't find rpcmethod: fetchData'

// after: update client to use the new method name
// URL: /MyService/fetchData
Defensive patterns

Strategy: validation

Validate before calling

// Verify the method exists on the stub before invoking
boolean exists = Arrays.stream(stub.getClass().getMethods())
    .anyMatch(m -> m.getName().equals(rpcMethodName));
if (!exists) {
    sendResponse.writeError(Status.UNIMPLEMENTED
        .withDescription("Unknown RPC method: " + rpcMethodName));
    return;
}

Try / catch

try {
    Method m = getRpcMethod(stub, rpcMethodName);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("Couldn't find rpcmethod")) {
        sendResponse.writeError(Status.UNIMPLEMENTED.withDescription(e.getMessage()));
    } else { throw e; }
}

Prevention

When it happens

Trigger: The URL specifies a method name that does not exist on the target gRPC stub class — e.g. a typo, a renamed method, or a method from a different service.

Common situations: Client uses an outdated method name after a proto schema change; method name casing mismatch after the proxy's lowercasing of the first character; the stub class was generated from a different .proto than the client expects; the class resolved isn't the intended gRPC service stub.

Related errors


AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14). Data as JSON: /api/errors/d93f59252b0e35f1. Report an issue: GitHub.