{"record":{"id":"cd7b2efb4b5157df","repo":"karatelabs/karate","slug":"cannot-find-resource-path","errorCode":null,"errorMessage":"cannot find resource: ${path}","messagePattern":"cannot find resource: (.+?)","errorType":"http","errorClass":"ResourceNotFoundException","httpStatus":404,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/markup/HtmlTemplateResolver.java","lineNumber":89,"sourceCode":"            prevCaller = null;\n            HtmlStringTemplateResource templateResource = new HtmlStringTemplateResource(content, resolver);\n            return new TemplateResolution(templateResource, TemplateMode.HTML, NonCacheableCacheEntryValidity.INSTANCE);\n        } else { // html file name\n            if (!content.endsWith(\".html\")) {\n                content = content + \".html\";\n            }\n            Resource caller;\n            // Only resolve ownerTemplate as caller if it's a valid template name (not HTML content or markers)\n            if (ownerTemplate != null && !ownerTemplate.startsWith(Resource.THIS_COLON) && prevCaller != null) {\n                // ownerTemplate needs .html extension too\n                String ownerPath = ownerTemplate.endsWith(\".html\") ? ownerTemplate : ownerTemplate + \".html\";\n                caller = resolver.resolve(ownerPath, null);\n            } else {\n                caller = prevCaller;\n            }\n            Resource resource = resolver.resolve(content, caller);\n            if (resource == null || !resource.exists()) {\n                throw new ResourceNotFoundException(content);\n            }\n            prevCaller = resource;\n            HtmlTemplateResource templateResource = new HtmlTemplateResource(ownerTemplate, resource);\n            return new TemplateResolution(templateResource, TemplateMode.HTML,\n                    devMode ? NonCacheableCacheEntryValidity.INSTANCE : AlwaysValidCacheEntryValidity.INSTANCE);\n        }\n    }\n\n}\n","sourceCodeStart":71,"sourceCodeEnd":99,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/markup/HtmlTemplateResolver.java#L71-L99","documentation":"HtmlTemplateResolver resolves template paths to Resources and throws ResourceNotFoundException (message 'cannot find resource: <path>') when the resolved resource is null or does not exist. This happens while loading a top-level template or while resolving an included/called fragment relative to the owner template.","triggerScenarios":"Rendering a template whose file path does not resolve under the configured root; an include/insert referencing a fragment file that is missing or misnamed; wrong working directory or classpath root so the resource cannot be located.","commonSituations":"Typo in template or fragment path; template file not copied into the build output/jar; configured template root points at the wrong directory; case-sensitive filesystems vs wrong-cased paths in CI/Linux.","solutions":["Verify the path in the error exists relative to the configured template root (check spelling and case)","Confirm the resource is on the classpath / copied into target output for jar deployments","Fix the resolver/root configuration (WorkingDir, resource root) to match where templates live","Check the calling fragment's relative path — includes resolve against the owner template's location"],"exampleFix":"// before\nkaThymeleaf.render(\"pages/dashborad.html\", model); // typo\n// after\nkaThymeleaf.render(\"pages/dashboard.html\", model);","handlingStrategy":"try-catch","validationCode":"Resource r = resolver.resolve(path, caller); if (r == null || !r.exists()) throw new IllegalStateException(\"template missing: \" + path);","typeGuard":null,"tryCatchPattern":"try { render(path, model); } catch (ResourceNotFoundException e) { log.error(\"template not found: {}\", e.getMessage()); throw e; }","preventionTips":["Verify template paths relative to the configured root (mind case sensitivity)","Ensure templates are copied into build output / packaged in the jar","Resolve includes relative to the calling template's directory","Add a startup smoke test that renders key templates"],"tags":["resource-not-found","template","classpath","file"],"backgroundTag":"resource-not-found","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"}