{"record":{"id":"c0b6cb5cd7f38ab1","repo":"OpenFeign/feign","slug":"jaxbcontextfactory-must-be-non-null-c0b6cb","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/SOAPEncoder.java","lineNumber":224,"sourceCode":"    }\n\n    /**\n     * The protocol used to create message factory. Default is \"SOAP 1.1 Protocol\".\n     *\n     * @param soapProtocol a string constant representing the MessageFactory protocol.\n     * @see SOAPConstants#SOAP_1_1_PROTOCOL\n     * @see SOAPConstants#SOAP_1_2_PROTOCOL\n     * @see SOAPConstants#DYNAMIC_SOAP_PROTOCOL\n     * @see MessageFactory#newInstance(String)\n     */\n    public Builder withSOAPProtocol(String soapProtocol) {\n      this.soapProtocol = soapProtocol;\n      return this;\n    }\n\n    public SOAPEncoder build() {\n      if (jaxbContextFactory == null) {\n        throw new IllegalStateException(\"JAXBContextFactory must be non-null\");\n      }\n      return new SOAPEncoder(this);\n    }\n  }\n\n  @Override\n  public boolean canEncode(Object object, Type bodyType, RequestTemplate template) {\n    return Util.isXmlContentType(template);\n  }\n}\n","sourceCodeStart":206,"sourceCodeEnd":235,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/soap/src/main/java/feign/soap/SOAPEncoder.java#L206-L235","documentation":"In the javax-based soap module, SOAPEncoder.Builder.build() fails fast with IllegalStateException if withJAXBContextFactory was not called, since the encoder cannot create Marshallers without the factory.","triggerScenarios":"Calling new SOAPEncoder.Builder().build() without supplying a JAXBContextFactory while configuring Feign's SOAP encoder.","commonSituations":"Omitted builder step; null injected factory; migrating between soap and soap-jakarta modules and losing the builder line.","solutions":["Add .withJAXBContextFactory(factory) to the builder before build().","Create one shared JAXBContextFactory for both encoder and decoder.","Check that the factory is constructed before client wiring code runs."],"exampleFix":"// before\nnew SOAPEncoder.Builder().build()\n// after\nnew SOAPEncoder.Builder().withJAXBContextFactory(factory).build()","handlingStrategy":"validation","validationCode":"JAXBContextFactory factory = /* shared instance */;\njava.util.Objects.requireNonNull(factory, \"factory required before SOAPEncoder build\");","typeGuard":null,"tryCatchPattern":"try {\n  encoder = new SOAPEncoder.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":["Build encoder with a factory in the same config block as the decoder.","Reuse one JAXBContextFactory across the app.","Add a configuration self-check at startup."],"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"}