flowable/flowable-engine · error · FlowableIllegalArgumentException
sessionJndi cannot be null
Error message
sessionJndi cannot be null
What it means
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.
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.
Example fix
// before
MailJndiServerConfiguration cfg = MailJndiServerConfiguration.of(properties.getProperty("mail.jndi")); // null
// after
String jndi = properties.getProperty("mail.jndi", "java:comp/env/mail/Session");
MailJndiServerConfiguration cfg = MailJndiServerConfiguration.of(jndi); Defensive patterns
Strategy: validation
Validate before calling
if (sessionJndi == null || sessionJndi.isBlank()) { throw new IllegalArgumentException("JNDI mail session name must be provided"); } Try / catch
try { cfg = MailJndiServerConfiguration.of(jndiName); } catch (FlowableIllegalArgumentException e) { cfg = MailServerConfiguration.of(host, port, user, pass); } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not send email: Incorrect JNDI configuration
- sessionJndi has to be set for
- activatedBefore is null
- activity tenant id is null
- activity tenant id is null
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/3846047244c6284d.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/MailJndiServerConfiguration.java:26
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.flowable.mail.common.impl;
import org.flowable.common.engine.api.FlowableIllegalArgumentException;
/**
* @author Filip Hrisafov
*/
public non-sealed interface MailJndiServerConfiguration extends MailServerConfiguration {
String getSessionJndi();
static MailJndiServerConfiguration of(String sessionJndi) {
if (sessionJndi == null) {
throw new FlowableIllegalArgumentException("sessionJndi cannot be null");
}
return () -> sessionJndi;
}
}
View on GitHub (pinned to d6d39ce1c6)