{"record":{"id":"59a0b148565fa0c6","repo":"karatelabs/karate","slug":"watch-mode-enabled-but-no-watchable-files-found-features-may","errorCode":null,"errorMessage":"watch mode enabled but no watchable files found - features may be from classpath JARs","messagePattern":"watch mode enabled but no watchable files found - features may be from classpath JARs","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/core/MockServer.java","lineNumber":400,"sourceCode":"            this.args = args;\n            this.pathPrefix = pathPrefix;\n            this.javaBridgeEnabled = javaBridgeEnabled;\n            this.requestExpressionsEnabled = requestExpressionsEnabled;\n\n            // Track file modification times for each feature\n            for (Feature feature : features) {\n                Resource resource = feature.getResource();\n                if (resource.isLocalFile()) {\n                    watchedFiles.put(resource, resource.getLastModified());\n                    logger.debug(\"watching file: {} (modified: {})\", resource.getRelativePath(), resource.getLastModified());\n                } else {\n                    logger.warn(\"watch mode: cannot watch non-file resource: {} (classpath resources in JARs are not watchable)\",\n                            resource.getRelativePath());\n                }\n            }\n\n            if (watchedFiles.isEmpty()) {\n                logger.warn(\"watch mode enabled but no watchable files found - features may be from classpath JARs\");\n            }\n\n            // Initialize handler\n            handler = new MockHandler(features, args, pathPrefix, javaBridgeEnabled, requestExpressionsEnabled);\n        }\n\n        MockHandler getHandler() {\n            return handler;\n        }\n\n        @Override\n        public HttpResponse apply(HttpRequest request) {\n            // Check if any watched file has been modified\n            boolean needsReload = false;\n            for (Map.Entry<Resource, Long> entry : watchedFiles.entrySet()) {\n                Resource resource = entry.getKey();\n                long lastKnown = entry.getValue();\n                long current = resource.getLastModified();","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/MockServer.java#L382-L418","documentation":"Watch mode was enabled on the mock server, but after scanning all supplied features, none resolved to local files, so the file watcher has nothing to monitor. Karate logs this warning and continues serving features, but no hot reload will ever occur.","triggerScenarios":"Every Feature passed to the ReloadingHandler comes from a non-local resource (classpath JARs); watchedFiles map ends up empty at MockServer startup with watch enabled.","commonSituations":"Mock server launched inside a packaged JAR; all features referenced with classpath: prefixes that resolve inside dependencies; running in a container from a single fat JAR expecting live-reload.","solutions":["Provide at least one feature from the local file system so the watcher has a file to monitor.","Copy features to a working directory at startup (e.g. in Docker: COPY to /features) and load from there.","Turn off watch mode since it cannot function in this deployment shape.","Run from an exploded directory layout instead of a JAR during development."],"exampleFix":"// before\nMockServer.feature(\"classpath:mocks/*.feature\").watch(true).build() // in fat JAR\n// after\nMockServer.feature(Paths.get(\"/app/features\")).watch(true).build()","handlingStrategy":"validation","validationCode":"boolean anyLocal = features.stream().anyMatch(f -> f.getResource().isLocalFile());\nif (watch && !anyLocal) throw new IllegalStateException(\"watch enabled but no local-file features\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify at least one feature resolves to a real file before enabling watch.","Copy packaged features to disk in container/deployment startup scripts.","Gate watch mode behind a dev-only flag."],"tags":["watch-mode","classpath","jar","config"],"backgroundTag":"missing-required-config-field","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"}