{"record":{"id":"526dd2b2f21b11f4","repo":"grpc/grpc-java","slug":"tls-not-supported-in-serverimplbuilder","errorCode":null,"errorMessage":"TLS not supported in ServerImplBuilder","messagePattern":"TLS not supported in ServerImplBuilder","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/grpc/internal/ServerImplBuilder.java","lineNumber":360,"sourceCode":"\n    @Nullable\n    @Override\n    public ServerMethodDefinition<?, ?> lookupMethod(\n        String methodName, @Nullable String authority) {\n      return null;\n    }\n  }\n\n  /**\n   * Returns the internal ExecutorPool for offloading tasks.\n   */\n  public ObjectPool<? extends Executor> getExecutorPool() {\n    return this.executorPool;\n  }\n\n  @Override\n  public ServerImplBuilder useTransportSecurity(File certChain, File privateKey) {\n    throw new UnsupportedOperationException(\"TLS not supported in ServerImplBuilder\");\n  }\n}\n","sourceCodeStart":342,"sourceCodeEnd":363,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/core/src/main/java/io/grpc/internal/ServerImplBuilder.java#L342-L363","documentation":"ServerImplBuilder is transport-agnostic and cannot wire TLS file-based transport security, which only concrete transports (netty, okhttp) can configure. Its useTransportSecurity(File,File) override therefore unconditionally throws UnsupportedOperationException.","triggerScenarios":"Calling useTransportSecurity(certChain, privateKey) on a ServerImplBuilder instance — e.g. obtained when ServerBuilder.forPort/forRegistry falls back without a transport provider, or through generic ServerBuilder code resolved to ServerImplBuilder.","commonSituations":"Same missing grpc-netty dependency scenario as forPort: code compiles against ServerBuilder but no concrete transport builder is present; framework code applying TLS config generically.","solutions":["Use a concrete transport builder (NettyServerBuilder) and call its useTransportSecurity or sslContext with the cert chain and private key","Add the grpc-netty (or other transport) dependency so the concrete builder is used","Configure TLS outside the builder (e.g. via Netty's SslContext / ProxyDetector-free TlsServerCredentials with ServerCredentials-based forPort APIs)"],"exampleFix":"// before\nServerBuilder<?> b = ServerBuilder.forPort(8080);\nb.useTransportSecurity(cert, key); // UnsupportedOperationException\n// after\nNettyServerBuilder b = NettyServerBuilder.forPort(8080);\nb.useTransportSecurity(cert, key);","handlingStrategy":"validation","validationCode":"if (b instanceof ServerImplBuilder) { /* cannot configure TLS here; use NettyServerBuilder or ServerCredentials */ }","typeGuard":"static boolean supportsTls(ServerBuilder<?> b) { return !(b instanceof io.grpc.internal.ServerImplBuilder); }","tryCatchPattern":"try { b.useTransportSecurity(cert, key); } catch (UnsupportedOperationException e) { if (e.getMessage().contains(\"TLS not supported\")) { /* rebuild with NettyServerBuilder */ } else throw e; }","preventionTips":["Configure TLS only on concrete transport builders or via ServerCredentials/TlsServerCredentials","Add grpc-netty before attempting transport security","Keep a single transport builder type in your server bootstrap code"],"tags":["grpc","tls","unsupported-operation","server-builder"],"backgroundTag":"unsupported-operation","analyzedSha":"64daddc1f3d1975670f769f3e97bde8b2ba32d25","analyzedAt":"2026-09-08T06:14:57.704Z","contentChangedAt":"2026-09-08T06:14:57.704Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}