{"record":{"id":"113e40ea2da60cce","repo":"OpenFeign/feign","slug":"jaxbcontextfactory-must-be-non-null-113e40","errorCode":null,"errorMessage":"JAXBContextFactory must be non-null","messagePattern":"JAXBContextFactory must be non-null","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"soap/src/main/java/feign/soap/SOAPDecoder.java","lineNumber":178,"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":160,"sourceCodeEnd":189,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/soap/src/main/java/feign/soap/SOAPDecoder.java#L160-L189","documentation":"In the javax-based soap module, SOAPDecoder.Builder.build() throws IllegalStateException when no JAXBContextFactory has been provided, because the decoder cannot create JAXB contexts to unmarshal SOAP bodies without it.","triggerScenarios":"Building a SOAPDecoder with new SOAPDecoder.Builder().build() and omitting .withJAXBContextFactory(...) during Feign client configuration.","commonSituations":"Missing builder step after refactoring; DI returning null factory; tutorial code trimmed the factory line.","solutions":["Call .withJAXBContextFactory(jaxbFactory) before build().","Construct the factory via new JAXBContextFactory.Builder().build() and store it once for encoder+decoder.","Add an assertion/check in configuration code that the factory is non-null before building."],"exampleFix":"// before\nnew SOAPDecoder.Builder().build()\n// after\nnew SOAPDecoder.Builder().withJAXBContextFactory(factory).build()","handlingStrategy":"validation","validationCode":"JAXBContextFactory factory = /* built once */;\njava.util.Objects.requireNonNull(factory, \"factory required before SOAPDecoder build\");","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    // supply factory and rebuild\n  }\n  throw e;\n}","preventionTips":["Keep a single shared JAXBContextFactory in configuration.","Never build SOAPDecoder in code that may run before factory initialization.","Validate wiring with a startup integration test."],"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"}