{"record":{"id":"303d2c0ce6e0e03b","repo":"OpenFeign/feign","slug":"jaxbcontextfactory-must-be-non-null-303d2c","errorCode":null,"errorMessage":"JAXBContextFactory must be non-null","messagePattern":"JAXBContextFactory must be non-null","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"jaxb/src/main/java/feign/jaxb/JAXBDecoder.java","lineNumber":122,"sourceCode":"\n  public static class Builder {\n    private boolean namespaceAware = true;\n    private JAXBContextFactory jaxbContextFactory;\n\n    /** Controls whether the underlying XML parser is namespace aware. Default is true. */\n    public Builder withNamespaceAware(boolean namespaceAware) {\n      this.namespaceAware = namespaceAware;\n      return this;\n    }\n\n    public Builder withJAXBContextFactory(JAXBContextFactory jaxbContextFactory) {\n      this.jaxbContextFactory = jaxbContextFactory;\n      return this;\n    }\n\n    public JAXBDecoder build() {\n      if (jaxbContextFactory == null) {\n        throw new IllegalStateException(\"JAXBContextFactory must be non-null\");\n      }\n      return new JAXBDecoder(this);\n    }\n  }\n\n  @Override\n  public boolean canDecode(Response response, Type type) {\n    return Util.isXmlContentType(response);\n  }\n}\n","sourceCodeStart":104,"sourceCodeEnd":133,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/jaxb/src/main/java/feign/jaxb/JAXBDecoder.java#L104-L133","documentation":"Same as error 101 in the javax jaxb module: JAXBDecoder.Builder.build() throws IllegalStateException when no JAXBContextFactory was provided, because the decoder cannot create unmarshallers without it.","triggerScenarios":"new JAXBDecoder.Builder().build() without supplying a JAXBContextFactory instance.","commonSituations":"Omitting the factory when wiring Feign.builder().decoder(...); incomplete copied configuration; a factory variable that is null after refactoring.","solutions":["Supply a factory: new JAXBDecoder.Builder(new JAXBContextFactory.Builder().build()).build().","Share one JAXBContextFactory instance between JAXBEncoder and JAXBDecoder.","Add a startup smoke test that builds the Feign client to validate wiring."],"exampleFix":"// before\nnew JAXBDecoder.Builder().build();\n// after\nnew JAXBDecoder.Builder(new JAXBContextFactory.Builder().build()).build();","handlingStrategy":"validation","validationCode":"// before building\nif (jaxbContextFactory == null) {\n  throw new IllegalStateException(\"JAXBContextFactory is required to build JAXBDecoder\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build JAXBContextFactory before constructing JAXBDecoder.","Share a single factory instance between encoder and decoder.","Cover client construction in a startup test."],"tags":["jaxb","configuration","illegal-state"],"backgroundTag":"missing-required-config-field","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"}