{"record":{"id":"6a0530523e903dce","repo":"OpenFeign/feign","slug":"jaxbcontextfactory-must-be-non-null","errorCode":null,"errorMessage":"JAXBContextFactory must be non-null","messagePattern":"JAXBContextFactory must be non-null","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"jaxb-jakarta/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-jakarta/src/main/java/feign/jaxb/JAXBDecoder.java#L104-L133","documentation":"JAXBDecoder.Builder.build() requires a JAXBContextFactory to have been set; if none was supplied it throws IllegalStateException. The decoder cannot create unmarshallers without the factory, so building without one is a configuration error detected immediately at construction time.","triggerScenarios":"Calling new JAXBDecoder.Builder().build() without first passing a JAXBContextFactory to the builder.","commonSituations":"Copying Feign.builder() wiring snippets and forgetting the factory argument; a refactoring that drops the factory parameter leaving it null.","solutions":["Pass a factory: new JAXBDecoder.Builder(new JAXBContextFactory.Builder().build()).build().","Construct the JAXBContextFactory once and share it between JAXBEncoder and JAXBDecoder.","If JAXB decoding is not needed, remove the decoder wiring instead of building an unconfigured one."],"exampleFix":"// before\nJAXBDecoder decoder = new JAXBDecoder.Builder().build();\n// after\nJAXBContextFactory factory = new JAXBContextFactory.Builder().build();\nJAXBDecoder decoder = new JAXBDecoder.Builder(factory).build();","handlingStrategy":"validation","validationCode":"// before building\nif (jaxbContextFactory == null) {\n  throw new IllegalStateException(\"provide a JAXBContextFactory before JAXBDecoder.Builder.build()\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always construct JAXBContextFactory first and pass it to both JAXBEncoder and JAXBDecoder builders.","Centralize encoder/decoder creation in one configuration factory method.","Add a startup integration test that builds the Feign client."],"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"}