{"record":{"id":"5aad4e600cbc1cf6","repo":"flowable/flowable-engine","slug":"problem-retrieving-activiti-context-xml-resources","errorCode":null,"errorMessage":"problem retrieving activiti-context.xml resources on the classpath: ${classpath}","messagePattern":"problem retrieving activiti-context\\.xml resources on the classpath: (.+?)","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/ProcessEngines.java","lineNumber":94,"sourceCode":"                resources = classLoader.getResources(\"flowable.cfg.xml\");\n            } catch (IOException e) {\n                throw new ActivitiIllegalArgumentException(\"problem retrieving flowable.cfg.xml resources on the classpath: \" + System.getProperty(\"java.class.path\"), e);\n            }\n\n            // Remove duplicated configuration URL's using set. Some classloaders may return identical URL's twice, causing duplicate startups\n            Set<URL> configUrls = new HashSet<>();\n            while (resources.hasMoreElements()) {\n                configUrls.add(resources.nextElement());\n            }\n            for (URL resource : configUrls) {\n                LOGGER.info(\"Initializing process engine using configuration '{}'\", resource);\n                initProcessEngineFromResource(resource);\n            }\n\n            try {\n                resources = classLoader.getResources(\"activiti-context.xml\");\n            } catch (IOException e) {\n                throw new ActivitiIllegalArgumentException(\"problem retrieving activiti-context.xml resources on the classpath: \" + System.getProperty(\"java.class.path\"), e);\n            }\n            while (resources.hasMoreElements()) {\n                URL resource = resources.nextElement();\n                LOGGER.info(\"Initializing process engine using Spring configuration '{}'\", resource);\n                initProcessEngineFromSpringResource(resource);\n            }\n\n            setInitialized(true);\n        } else {\n            LOGGER.info(\"Process engines already initialized\");\n        }\n    }\n\n    protected static void initProcessEngineFromSpringResource(URL resource) {\n        try {\n            Class<?> springConfigurationHelperClass = ReflectUtil.loadClass(\"org.activiti.spring.SpringConfigurationHelper\");\n            Method method = springConfigurationHelperClass.getDeclaredMethod(\"buildProcessEngine\", new Class<?>[]{URL.class});\n            ProcessEngine processEngine = (ProcessEngine) method.invoke(null, new Object[]{resource});","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/ProcessEngines.java#L76-L112","documentation":"Same classpath scan as 4076 but for activiti-context.xml Spring configuration resources; an IOException from ClassLoader.getResources is wrapped in this ActivitiIllegalArgumentException with the classpath appended. It means the engine initializer could not enumerate Spring context resources.","triggerScenarios":"ProcessEngines.init() iterating activiti-context.xml resources when the classloader's getResources call fails with IOException.","commonSituations":"Legacy Activiti-style Spring auto-discovery (activiti-context.xml) in environments where classloader resource enumeration is broken or restricted.","solutions":["Fix the classloader environment so getResources works (check container restrictions)","Bypass auto-discovery and build the engine from the Spring application context directly via SpringProcessEngineConfiguration","Remove stale activiti-context.xml expectations if you no longer use Spring auto-discovery"],"exampleFix":"// before\nProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); // scans activiti-context.xml\n// after\nProcessEngine engine = new SpringProcessEngineConfiguration()\n    .setApplicationContext(ctx)\n    .buildProcessEngine();","handlingStrategy":"fallback","validationCode":"if (getClass().getClassLoader().getResource(\"activiti-context.xml\") == null\n    && expectSpringAutoDiscovery) {\n  log.warn(\"activiti-context.xml missing from classpath\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  engine = ProcessEngines.getDefaultProcessEngine();\n} catch (ActivitiIllegalArgumentException e) {\n  if (e.getMessage().contains(\"activiti-context.xml\"))\n    engine = new SpringProcessEngineConfiguration().setApplicationContext(ctx).buildProcessEngine();\n  else throw e;\n}","preventionTips":["Prefer explicit SpringProcessEngineConfiguration over classpath auto-discovery","Keep activiti-context.xml at the classpath root if you rely on auto-discovery","Test engine bootstrap in the target container's classloading environment"],"tags":["classpath","spring","initialization","flowable"],"backgroundTag":"file-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}