{"record":{"id":"2589ec38620cfd02","repo":"spring-projects/spring-security","slug":"unable-to-resolve-builder-for-2589ec","errorCode":null,"errorMessage":"Unable to resolve Builder for ","messagePattern":"Unable to resolve Builder for ","errorType":"exception","errorClass":"Saml2Exception","httpStatus":null,"severity":"error","filePath":"saml2/saml2-service-provider/src/opensaml5Main/java/org/springframework/security/saml2/provider/service/web/authentication/logout/OpenSaml5Template.java","lineNumber":132,"sourceCode":"import org.springframework.security.saml2.core.Saml2ParameterNames;\nimport org.springframework.security.saml2.core.Saml2X509Credential;\nimport org.springframework.util.Assert;\nimport org.springframework.web.util.UriComponentsBuilder;\nimport org.springframework.web.util.UriUtils;\n\n/**\n * For internal use only. Subject to breaking changes at any time.\n */\n@NullMarked\nfinal class OpenSaml5Template implements OpenSamlOperations {\n\n\tprivate static final Log logger = LogFactory.getLog(OpenSaml5Template.class);\n\n\t@Override\n\tpublic <T extends XMLObject> T build(QName elementName) {\n\t\tXMLObjectBuilder<?> builder = XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(elementName);\n\t\tif (builder == null) {\n\t\t\tthrow new Saml2Exception(\"Unable to resolve Builder for \" + elementName);\n\t\t}\n\t\treturn (T) builder.buildObject(elementName);\n\t}\n\n\t@Override\n\tpublic <T extends XMLObject> T deserialize(String serialized) {\n\t\treturn deserialize(new ByteArrayInputStream(serialized.getBytes(StandardCharsets.UTF_8)));\n\t}\n\n\t@Override\n\tpublic <T extends XMLObject> T deserialize(InputStream serialized) {\n\t\ttry {\n\t\t\tParserPool pool = XMLObjectProviderRegistrySupport.getParserPool();\n\t\t\tAssert.notNull(pool, \"ParserPool must be configured\");\n\t\t\tDocument document = pool.parse(serialized);\n\t\t\tElement element = document.getDocumentElement();\n\t\t\tUnmarshallerFactory factory = XMLObjectProviderRegistrySupport.getUnmarshallerFactory();\n\t\t\tUnmarshaller unmarshaller = factory.getUnmarshaller(element);","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/spring-projects/spring-security/blob/96852e8860138a482cb13d1479573f24ff6443c6/saml2/saml2-service-provider/src/opensaml5Main/java/org/springframework/security/saml2/provider/service/web/authentication/logout/OpenSaml5Template.java#L114-L150","documentation":"Identical to error 580 but in the logout package's OpenSaml5Template: build() throws this Saml2Exception when OpenSAML's XMLObjectBuilderFactory has no builder registered for the given QName, so the requested SAML element cannot be constructed.","triggerScenarios":"Calling the logout OpenSaml5Template.build(QName) with an element name for which getBuilderFactory().getBuilder(elementName) returns null (unregistered/unknown element).","commonSituations":"Building LogoutRequest/LogoutResponse with a hand-crafted QName instead of the *.DEFAULT_ELEMENT_NAME constants; OpenSAML registry not initialized; duplicate OpenSAML 4/5 jars; using extension elements whose providers were never registered.","solutions":["Initialize OpenSAML via OpenSamlInitializationService.initialize() before calling build().","Use canonical constants like LogoutRequest.DEFAULT_ELEMENT_NAME rather than manually constructed QNames.","Remove conflicting OpenSAML versions from the classpath and confirm providers load at startup.","For custom elements, register an XMLObjectBuilder in the XMLObjectProviderRegistry."],"exampleFix":"// before\nQName q = new QName(\"LogoutRequest\");\nLogoutRequest req = template.build(q);\n\n// after\nOpenSamlInitializationService.initialize();\nLogoutRequest req = template.build(LogoutRequest.DEFAULT_ELEMENT_NAME);","handlingStrategy":"validation","validationCode":"OpenSamlInitializationService.initialize();\nif (XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(elementName) == null) {\n    throw new IllegalStateException(\"No OpenSAML builder for \" + elementName);\n}","typeGuard":null,"tryCatchPattern":"try { T obj = template.build(elementName); } catch (Saml2Exception ex) { log.error(\"Logout template cannot build {}\", elementName, ex); throw ex; }","preventionTips":["Initialize OpenSAML registry at startup","Use LogoutRequest.DEFAULT_ELEMENT_NAME / LogoutResponse.DEFAULT_ELEMENT_NAME constants","Avoid duplicate OpenSAML 4/5 dependencies"],"tags":["saml","opensaml","logout","spring-security","initialization"],"backgroundTag":"module-init-failed","analyzedSha":"96852e8860138a482cb13d1479573f24ff6443c6","analyzedAt":"2026-09-10T23:25:23.477Z","contentChangedAt":"2026-09-10T23:25:23.477Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}