{"record":{"id":"2550fe3f83f1edac","repo":"OpenFeign/feign","slug":"jaxbcontextfactory-must-be-non-null-2550fe","errorCode":null,"errorMessage":"JAXBContextFactory must be non-null","messagePattern":"JAXBContextFactory must be non-null","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"soap-jakarta/src/main/java/feign/soap/SOAPDecoder.java","lineNumber":174,"sourceCode":"    public Builder withSOAPProtocol(String soapProtocol) {\n      this.soapProtocol = soapProtocol;\n      return this;\n    }\n\n    /**\n     * Alters the behavior of the code to use the {@link SOAPBody#getFirstChild()} in place of\n     * {@link SOAPBody#extractContentAsDocument()}.\n     *\n     * @return the builder instance.\n     */\n    public Builder useFirstChild() {\n      this.useFirstChild = true;\n      return this;\n    }\n\n    public SOAPDecoder build() {\n      if (jaxbContextFactory == null) {\n        throw new IllegalStateException(\"JAXBContextFactory must be non-null\");\n      }\n      return new SOAPDecoder(this);\n    }\n  }\n\n  @Override\n  public boolean canDecode(Response response, Type type) {\n    return Util.isXmlContentType(response);\n  }\n}\n","sourceCodeStart":156,"sourceCodeEnd":185,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/soap-jakarta/src/main/java/feign/soap/SOAPDecoder.java#L156-L185","documentation":"SOAPDecoder.Builder requires a JAXBContextFactory to create JAXB contexts for unmarshalling SOAP bodies; build() refuses to construct a decoder without one by throwing IllegalStateException. This is a fail-fast builder check so misconfiguration surfaces at wiring time, not on first response.","triggerScenarios":"Calling new SOAPDecoder.Builder().build() (or omitting .withJAXBContextFactory(...)) while configuring the Feign encoder/decoder for the soap-jakarta module.","commonSituations":"Copy-pasting a decoder setup from the plain JAXB module and forgetting the factory; assuming a default factory exists; DI wiring that leaves the factory null.","solutions":["Call .withJAXBContextFactory(new JAXBContextFactory.Builder().build()) on SOAPDecoder.Builder before build().","Reuse one shared JAXBContextFactory instance for both SOAPEncoder and SOAPDecoder builders.","Ensure your DI framework actually injects a non-null factory into the configuration code."],"exampleFix":"// before\nSOAPDecoder decoder = new SOAPDecoder.Builder().build();\n// after\nSOAPDecoder decoder = new SOAPDecoder.Builder()\n    .withJAXBContextFactory(jaxbFactory)\n    .build();","handlingStrategy":"validation","validationCode":"JAXBContextFactory factory = /* built once */;\njava.util.Objects.requireNonNull(factory, \"JAXBContextFactory must be created before building SOAPDecoder\");","typeGuard":null,"tryCatchPattern":"try {\n  decoder = new SOAPDecoder.Builder().withJAXBContextFactory(factory).build();\n} catch (IllegalStateException e) {\n  if (\"JAXBContextFactory must be non-null\".equals(e.getMessage())) {\n    throw new IllegalStateException(\"Decoder misconfigured: supply JAXBContextFactory\", e);\n  }\n  throw e;\n}","preventionTips":["Create one JAXBContextFactory bean and share it for encoder and decoder.","Build the factory before any Feign client wiring code.","Fail fast in DI setup if the factory is null."],"tags":["soap","jaxb","builder","configuration","null-check"],"backgroundTag":"missing-required-argument","analyzedSha":"e2a1e27560a1e68840c34f031afca88b36096e30","analyzedAt":"2026-09-10T12:37:37.238Z","contentChangedAt":"2026-09-10T12:37:37.238Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}