{"record":{"id":"23161f49289d2a7b","repo":"apereo/cas","slug":"unable-to-locate-a-matching-service-definition-fro","errorCode":null,"errorMessage":"Unable to locate a matching service definition from file [{}]. Reloading cache...","messagePattern":"Unable to locate a matching service definition from file \\[(.+?)\\]\\. Reloading cache\\.\\.\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/cas-server-core-services-registry/src/main/java/org/apereo/cas/services/resource/DeleteResourceBasedRegisteredServiceWatcher.java","lineNumber":37,"sourceCode":"\n    public DeleteResourceBasedRegisteredServiceWatcher(final AbstractResourceBasedServiceRegistry serviceRegistryDao) {\n        super(serviceRegistryDao);\n    }\n\n    @Override\n    public void accept(final File file) {\n        val fileName = file.getName();\n        if (!(!fileName.isEmpty() && fileName.charAt(0) == '.') && Arrays.stream(serviceRegistryDao.getExtensions()).anyMatch(fileName::endsWith)) {\n            LOGGER.debug(\"Service definition [{}] was deleted. Reloading cache...\", file);\n            val service = serviceRegistryDao.getRegisteredServiceFromFile(file);\n            val clientInfo = ClientInfoHolder.getClientInfo();\n            if (service != null) {\n                serviceRegistryDao.publishEvent(new CasRegisteredServicePreDeleteEvent(this, service, clientInfo));\n                serviceRegistryDao.removeRegisteredService(service);\n                LOGGER.debug(\"Successfully deleted service definition [{}]\", service.getName());\n                serviceRegistryDao.publishEvent(new CasRegisteredServiceDeletedEvent(this, service, clientInfo));\n            } else {\n                LOGGER.warn(\"Unable to locate a matching service definition from file [{}]. Reloading cache...\", file);\n                val results = serviceRegistryDao.load();\n                serviceRegistryDao.publishEvent(new CasRegisteredServicesLoadedEvent(this, results, clientInfo));\n            }\n        }\n    }\n}\n","sourceCodeStart":19,"sourceCodeEnd":44,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/core/cas-server-core-services-registry/src/main/java/org/apereo/cas/services/resource/DeleteResourceBasedRegisteredServiceWatcher.java#L19-L44","documentation":"DeleteResourceBasedRegisteredServiceWatcher.accept handles service file deletions. It parses the deleted file to find the matching registered service; if none is found in memory, it logs this warning and falls back to a full cache reload (serviceRegistryDao.load()) plus a CasRegisteredServicesLoadedEvent to resynchronize.","triggerScenarios":"A service file is deleted from the watched directory while the corresponding RegisteredService is not present in the in-memory registry (e.g. file never loaded, id mismatch, stale watcher event); findServiceBy lookup returns null.","commonSituations":"Deleting files by hand before CAS finished loading; filename id not matching the JSON id so the lookup misses; external sync tools (rsync, git checkout) deleting files mid-run.","solutions":["No action strictly required — CAS reloads the whole cache automatically to resync.","Ensure filename ids match the JSON 'id' fields so future deletes resolve directly.","Avoid bulk file operations while CAS is running; perform them during maintenance windows and then trigger a registry reload."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match filename ids with JSON 'id' fields so delete events resolve without full reloads.","Batch or stagger external file deletions (rsync/git) rather than racing the watcher.","Rely on the automatic cache reload; verify registry state after bulk deletions."],"tags":["watcher","service-registry","cache"],"backgroundTag":"entity-not-found","analyzedSha":"e7288fc434b4f4505b8452e1a57e8fb3111bb863","analyzedAt":"2026-09-08T15:39:16.015Z","contentChangedAt":"2026-09-08T15:39:16.015Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}