{"record":{"id":"fb7c52e8cf67c6e4","repo":"karatelabs/karate","slug":"cannot-find","errorCode":null,"errorMessage":"cannot find [","messagePattern":"cannot find \\[","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/KarateJs.java","lineNumber":1231,"sourceCode":"                    // mirroring boot.ext: channel('grpc') -> io.karatelabs.ext.grpc.GrpcChannelFactory.\n                    String cap = Character.toUpperCase(type.charAt(0)) + type.substring(1);\n                    String factoryClass = \"io.karatelabs.ext.\" + type + \".\" + cap + \"ChannelFactory\";\n                    Class<?> clazz = Class.forName(factoryClass);\n                    factory = (ChannelFactory) clazz.getDeclaredConstructor().newInstance();\n                }\n                // Channels self-configure via their rich JS object, not via global config.\n                Channel channel = factory.create(rt, new HashMap<>());\n                rt.registerChannel(channel);\n                return channel.init(rt);\n            } catch (RuntimeException re) {\n                throw re;\n            } catch (ClassNotFoundException e) {\n                // Name every way the leaf actually arrives. \"is it a maven / gradle dependency?\" is only\n                // one of them, and it is the wrong question for a run inside a packaged engine — where\n                // the answer is to run (or add) the jar that carries the leaf, not to edit a build file\n                // that is not there. A message that names a fix nobody in that context can perform reads\n                // as \"this capability is broken\".\n                throw new RuntimeException(\"cannot find [\" + type + \"]: no channel factory is registered for\"\n                        + \" it and io.karatelabs.ext.\" + type + \".\" + Character.toUpperCase(type.charAt(0))\n                        + type.substring(1) + \"ChannelFactory is not on the classpath. Add the 'karate-\"\n                        + type + \"' dependency (maven / gradle), or run an engine jar that bundles the\"\n                        + \" protocol leaves, or put the leaf jar on the classpath.\");\n            } catch (Exception e) {\n                throw new RuntimeException(e.getMessage(), e);\n            }\n        };\n    }\n\n    @Override\n    public Object jsGet(String key) {\n        return switch (key) {\n            // Stateless utility methods (KarateJsApi)\n            case \"append\" -> KarateJsUtils.append();\n            case \"appendTo\" -> KarateJsUtils.appendTo();\n            case \"distinct\" -> KarateJsUtils.distinct();\n            case \"extract\" -> KarateJsUtils.extract();","sourceCodeStart":1213,"sourceCodeEnd":1249,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/KarateJs.java#L1213-L1249","documentation":"karate.channel(type) first checks factories registered on the Suite, then falls back to the naming convention io.karatelabs.ext.<Type>.<Type>ChannelFactory loaded reflectively. When the class cannot be found, this rich error explains that no factory is registered and the protocol's leaf jar (e.g. karate-kafka) is not on the classpath, and lists the concrete fixes.","triggerScenarios":"karate.channel('kafka') (or any protocol type) when the karate-<type> module/extension jar is absent from the runtime classpath and no factory was registered via Suite#registerChannelFactory; running a slim/packaged engine jar without bundled protocol leaves; a typo'd type name that matches no factory or class.","commonSituations":"Maven/Gradle project missing the karate-kafka / karate-grpc style dependency; custom distribution built without protocol modules; running inside a repackaged engine where editing a build file is not an option and the leaf jar must be bundled; spelling the type differently from the module name.","solutions":["Add the protocol dependency to the build: e.g. io.karatelabs:karate-kafka (matching your Karate version)","If running a packaged engine jar, use one that bundles the protocol leaf or place the leaf jar on the classpath","Register a custom ChannelFactory on the Suite at boot (Suite#registerChannelFactory) for custom protocols","Verify the type string exactly matches the module/factory name (case-sensitive first letter is capitalized for the class lookup)."],"exampleFix":"// before (pom.xml) — no leaf dependency\n<dependency><groupId>io.karatelabs</groupId><artifactId>karate-core</artifactId></dependency>\n// after\n<dependency><groupId>io.karatelabs</groupId><artifactId>karate-core</artifactId></dependency>\n<dependency><groupId>io.karatelabs</groupId><artifactId>karate-kafka</artifactId><version>${karate.version}</version></dependency>","handlingStrategy":"try-catch","validationCode":"// build check: ensure the leaf jar exists on the classpath before running\n// mvn dependency:tree | grep karate-kafka","typeGuard":null,"tryCatchPattern":"try { var ch = karate.channel('kafka'); } catch (e) { if (String(e).indexOf('cannot find [') >= 0) karate.warn('add the karate-<type> dependency or leaf jar to the classpath'); throw e; }","preventionTips":["Add io.karatelabs:karate-<protocol> dependencies matching your Karate version","Verify with mvn dependency:tree / gradle dependencies that the leaf jar is present","Register custom ChannelFactory via Suite#registerChannelFactory for custom protocols","Keep the type string exact; the class lookup capitalizes the first letter"],"tags":["classpath","missing-dependency","channels","karate-js"],"backgroundTag":"missing-dependency","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}