{"record":{"id":"d0e948d1b19a3a1e","repo":"karatelabs/karate","slug":"watch-mode-cannot-watch-non-file-resource-classpath","errorCode":null,"errorMessage":"watch mode: cannot watch non-file resource: {} (classpath resources in JARs are not watchable)","messagePattern":"watch mode: cannot watch non-file resource: (.+?) \\(classpath resources in JARs are not watchable\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/core/MockServer.java","lineNumber":394,"sourceCode":"        private final boolean javaBridgeEnabled;\n        private final boolean requestExpressionsEnabled;\n        private final Map<Resource, Long> watchedFiles = new LinkedHashMap<>();\n        private MockHandler handler;\n\n        ReloadingHandler(List<Feature> features, Map<String, Object> args, String pathPrefix, boolean javaBridgeEnabled, boolean requestExpressionsEnabled) {\n            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) {","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/MockServer.java#L376-L412","documentation":"Mock server watch/reload mode was enabled, but one of the loaded features comes from a Resource that is not a local file (e.g. packaged inside a JAR on the classpath). File-modification-based watching is impossible for such resources, so Karate logs a warning and skips watching that feature; it will be served but never hot-reloaded.","triggerScenarios":"Starting MockServer with reload/watch enabled while passing features loaded via classpath: references that resolve to entries inside JARs, or any resource where resource.isLocalFile() is false.","commonSituations":"Running mocks against a fat JAR or shaded build; features bundled in a test-jar dependency; IDE running with features copied to a build output JAR; Docker image containing features inside an app JAR.","solutions":["Pass file-system paths (File or the feature file directly on disk) instead of classpath resources to the mock server builder.","Extract/copy the features to a local directory before starting the mock server and watch that directory.","Disable watch/reload mode if hot reload is not needed — the warning is otherwise harmless.","Run with an exploded classpath (target/classes, target/test-classes) rather than a JAR during development."],"exampleFix":"// before\nMockServer.feature(\"classpath:mock/feature.feature\").watch(true).build()\n// after\nMockServer.feature(\"src/test/resources/mock/feature.feature\").watch(true).build()","handlingStrategy":"validation","validationCode":"Resource r = feature.getResource();\nif (!r.isLocalFile()) throw new IllegalStateException(\"watch mode needs local file, got: \" + r.getRelativePath());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Load features from file-system paths when using watch mode.","Run mocks from an exploded classpath during development.","Only enable watch mode in dev profiles, never in packaged deployments."],"tags":["watch-mode","classpath","jar","hot-reload"],"backgroundTag":"unsupported-operation","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"}