{"record":{"id":"69c4fd943278f45b","repo":"flowable/flowable-engine","slug":"unsupported-server-configuration","errorCode":null,"errorMessage":"Unsupported server configuration ","messagePattern":"Unsupported server configuration ","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/jakarta/mail/JakartaMailFlowableMailClient.java","lineNumber":346,"sourceCode":"                    bodyPart.setFileName(MimeUtility.encodeText(attachment.getName(), charset, null));\n                } catch (UnsupportedEncodingException e) {\n                    throw new FlowableMailException(\"Could not encode attachment file name\", e);\n                }\n                bodyPart.setDataHandler(new DataHandler(attachment));\n                rootContainer.addBodyPart(bodyPart);\n            }\n        }\n\n        return rootContainer;\n    }\n\n    protected Session createSession() {\n        if (serverConfiguration instanceof MailJndiServerConfiguration jndiServerConfiguration) {\n            return createSession(jndiServerConfiguration);\n        } else if (serverConfiguration instanceof MailHostServerConfiguration hostServerConfiguration) {\n            return createSession(hostServerConfiguration);\n        } else {\n            throw new FlowableException(\"Unsupported server configuration \" + serverConfiguration);\n        }\n    }\n\n    protected Session createSession(MailJndiServerConfiguration serverConfiguration) {\n        String sessionJndi = serverConfiguration.getSessionJndi();\n        if (sessionJndi == null) {\n            throw new FlowableIllegalArgumentException(\"sessionJndi has to be set for \" + serverConfiguration);\n        }\n        try {\n            Context ctx;\n            if (sessionJndi.startsWith(\"java:\")) {\n                ctx = new InitialContext();\n            } else {\n                ctx = (Context) new InitialContext().lookup(\"java:comp/env\");\n\n            }\n\n            return (Session) ctx.lookup(sessionJndi);","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/jakarta/mail/JakartaMailFlowableMailClient.java#L328-L364","documentation":"createSession() dispatches on the type of the configured serverConfiguration: it supports MailJndiServerConfiguration and MailHostServerConfiguration. Any other implementation type reaches the else branch and throws FlowableException \"Unsupported server configuration <config>\". The message conveniently echoes the object via toString().","triggerScenarios":"Registering a custom ServerConfiguration implementation (or a mock/anonymous object) that is neither MailJndiServerConfiguration nor MailHostServerConfiguration, then triggering mail session creation by sending an email.","commonSituations":"Custom mail configuration extension code after a Flowable upgrade (pattern matching in switch became exhaustive on known types); passing the wrong configuration object type from plugin code; unit tests stubbing ServerConfiguration with a generic fake.","solutions":["Log/print the configuration object class to see what was actually injected","Use MailHostServerConfiguration (host/port/credentials) for standard SMTP setups","Use MailJndiServerConfiguration when the mail session comes from JNDI","Make custom configurations extend one of the two supported classes instead of implementing the interface directly"],"exampleFix":"// before\nServerConfiguration cfg = new MyCustomMailConfig();\n// after\nMailHostServerConfiguration cfg = new MailHostServerConfiguration(\n    \"smtp.example.com\", 587, \"user\", \"pass\", true, false, null);\nmailClient.setServerConfiguration(cfg);","handlingStrategy":"type-guard","validationCode":"if (!(serverConfiguration instanceof MailJndiServerConfiguration)\n        && !(serverConfiguration instanceof MailHostServerConfiguration)) {\n    throw new IllegalArgumentException(\n        \"ServerConfiguration must be MailJndi or MailHost: \" + serverConfiguration.getClass());\n}","typeGuard":"boolean isSupportedConfig(ServerConfiguration cfg) {\n    return cfg instanceof MailJndiServerConfiguration || cfg instanceof MailHostServerConfiguration;\n}","tryCatchPattern":"try {\n    mailClient.send(mailMessage);\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"Unsupported server configuration\")) {\n        log.error(\"Injected config type: {}\", mailClient.getServerConfiguration().getClass());\n    }\n}","preventionTips":["Only instantiate MailHostServerConfiguration or MailJndiServerConfiguration","After Flowable upgrades, re-check custom configuration classes still extend supported types","Add an assertion on config type at engine bootstrap"],"tags":["mail","configuration","type-mismatch","smtp"],"backgroundTag":"unsupported-operation","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}