{"record":{"id":"a6cc4e71a8b13e5f","repo":"apereo/cas","slug":"could-not-retrieve-input-stream-from-resource-mov","errorCode":null,"errorMessage":"Could not retrieve input stream from resource. Moving on...","messagePattern":"Could not retrieve input stream from resource\\. Moving on\\.\\.\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"support/cas-server-support-saml-mdui-core/src/main/java/org/apereo/cas/support/saml/mdui/AbstractMetadataResolverAdapter.java","lineNumber":119,"sourceCode":"        LOGGER.debug(\"Locating metadata resource from input stream.\");\n        if (!resource.exists() || !resource.isReadable()) {\n            throw new FileNotFoundException(\"Resource does not exist or is unreadable\");\n        }\n        return resource.getInputStream();\n    }\n\n    private List<MetadataResolver> loadMetadataFromResource(final MetadataFilter metadataFilter, final Resource resource,\n                                                            final String entityId) {\n        LOGGER.debug(\"Evaluating metadata resource [{}]\", resource.getFilename());\n        try (val in = getResourceInputStream(resource, entityId)) {\n            if (in.available() > 0) {\n                LOGGER.debug(\"Parsing [{}]\", resource.getFilename());\n                val document = this.configBean.getParserPool().parse(in);\n                return buildSingleMetadataResolver(metadataFilter, resource, document);\n            }\n            LOGGER.warn(\"Input stream from resource [{}] appears empty. Moving on...\", resource.getFilename());\n        } catch (final Exception e) {\n            LoggingUtils.warn(LOGGER, \"Could not retrieve input stream from resource. Moving on...\", e);\n        }\n        return new ArrayList<>();\n    }\n\n    /**\n     * Build single metadata resolver.\n     *\n     * @param metadataFilterChain the metadata filters chained together\n     * @param resource            the resource\n     * @param document            the xml document to parse\n     * @return list of resolved metadata from resources.\n     */\n    private List<MetadataResolver> buildSingleMetadataResolver(final MetadataFilter metadataFilterChain, final Resource resource,\n                                                               final Document document) {\n        val metadataRoot = document.getDocumentElement();\n        val metadataProvider = new DOMMetadataResolver(metadataRoot);\n        metadataProvider.setParserPool(this.configBean.getParserPool());\n        metadataProvider.setFailFastInitialization(true);","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/support/cas-server-support-saml-mdui-core/src/main/java/org/apereo/cas/support/saml/mdui/AbstractMetadataResolverAdapter.java#L101-L137","documentation":"The MDUI metadata loader could not obtain an input stream for a metadata resource (or parsing threw), caught the exception, logged this warning with the cause, and skipped the resource by returning an empty list.","triggerScenarios":"getResourceInputStream(resource, entityId) throws (resource missing, unreadable, URL unreachable) or ParserPool.parse fails inside loadMetadataFromResource — the generic catch logs \"Could not retrieve input stream from resource. Moving on...\".","commonSituations":"File path typo or missing permissions; HTTP metadata URL returning 404/403/DNS failure; malformed XML that the parser rejects; container lacking network egress.","solutions":["Read the full stack trace attached by LoggingUtils.warn to identify root cause (IO vs parse).","Verify the resource path/URL is correct and accessible from the CAS process user.","Test the URL with curl (status code, content) or the file with an XML validator.","Fix file permissions (chmod/chown) or network/firewall egress for remote metadata."],"exampleFix":"// before (unreachable URL)\nmetadata: https://internal.invalid/idp-metadata.xml\n// after\nmetadata: file:/etc/cas/mdui/idp-metadata.xml","handlingStrategy":"try-catch","validationCode":"try (var in = new FileInputStream(path)) {\n    // ensure readable before handing to resolver\n} catch (IOException e) {\n    LOGGER.error(\"Metadata unreadable: {}\", path, e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    loadMetadata(resource);\n} catch (Exception e) {\n    LOGGER.warn(\"Could not load metadata resource {}\", resource, e);\n    // continue with remaining resources\n}","preventionTips":["Check file permissions and paths for all MDUI metadata resources at deployment.","Curl-test remote metadata URLs from the CAS host.","Validate metadata XML against the SAML schema before deployment."],"tags":["metadata","io","resource"],"backgroundTag":"file-open-failed","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"}