{"record":{"id":"3846047244c6284d","repo":"flowable/flowable-engine","slug":"sessionjndi-cannot-be-null","errorCode":null,"errorMessage":"sessionJndi cannot be null","messagePattern":"sessionJndi cannot be null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/MailJndiServerConfiguration.java","lineNumber":26,"sourceCode":" * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage org.flowable.mail.common.impl;\n\nimport org.flowable.common.engine.api.FlowableIllegalArgumentException;\n\n/**\n * @author Filip Hrisafov\n */\npublic non-sealed interface MailJndiServerConfiguration extends MailServerConfiguration {\n\n    String getSessionJndi();\n\n    static MailJndiServerConfiguration of(String sessionJndi) {\n        if (sessionJndi == null) {\n            throw new FlowableIllegalArgumentException(\"sessionJndi cannot be null\");\n        }\n        return () -> sessionJndi;\n    }\n\n}\n","sourceCodeStart":8,"sourceCodeEnd":32,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/MailJndiServerConfiguration.java#L8-L32","documentation":"The MailJndiServerConfiguration.of factory creates a mail server configuration backed by a JNDI mail Session. It validates its single argument and throws FlowableIllegalArgumentException when the JNDI name is null, since a JNDI-based configuration without a lookup name is meaningless.","triggerScenarios":"Calling MailJndiServerConfiguration.of(null) — e.g. when the JNDI session name is read from a property/env var that is absent and passed straight into the factory.","commonSituations":"Spring/EE deployments where the mail session JNDI name is externalized to configuration and the key is missing; refactoring from hostname-based to JNDI-based mail config where the lookup name was never supplied.","solutions":["Pass a valid, non-null JNDI name, e.g. MailJndiServerConfiguration.of(\"java:comp/env/mail/Session\").","Fix the configuration source so the JNDI name is actually populated before constructing the mail client.","If no JNDI session exists, use a host/port-based MailServerConfiguration instead of the JNDI variant."],"exampleFix":"// before\nMailJndiServerConfiguration cfg = MailJndiServerConfiguration.of(properties.getProperty(\"mail.jndi\")); // null\n\n// after\nString jndi = properties.getProperty(\"mail.jndi\", \"java:comp/env/mail/Session\");\nMailJndiServerConfiguration cfg = MailJndiServerConfiguration.of(jndi);","handlingStrategy":"validation","validationCode":"if (sessionJndi == null || sessionJndi.isBlank()) { throw new IllegalArgumentException(\"JNDI mail session name must be provided\"); }","typeGuard":null,"tryCatchPattern":"try { cfg = MailJndiServerConfiguration.of(jndiName); } catch (FlowableIllegalArgumentException e) { cfg = MailServerConfiguration.of(host, port, user, pass); }","preventionTips":["Fail fast at startup if the JNDI name property is missing.","Provide sane defaults (e.g. java:comp/env/mail/Session) for the lookup name.","Document which config key supplies the JNDI name to operators."],"tags":["mail","jndi","null-argument","factory"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}