Issue
How can I resolve this exception observed during initialization of global JNDI resources during Liferay startup on Tomcat?
org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans Exception processing global JNDI Resources javax.naming.NamingException: Could not create resource factory instance [Root exception is java.lang.NoClassDefFoundError: javax/mail/Authenticator] at org.apache.naming.factory.ResourceFactory.getDefaultFactory(ResourceFactory.java:74)
...
Caused by: java.lang.NoClassDefFoundError: javax/mail/Authenticator
Environment
-
DXP 7.4+
Resolution
Though an official solution is being explored on LPD-64152, you can follow the below steps to resolve these JNDI Mail Session errors on Tomcat:
-
Shutdown Liferay
-
Move the following libraries from
[TOMCAT_HOME]/webapps/ROOT/WEB-INF/shielded-container-libto[TOMCAT_HOME]/lib:-
activation.jar -
com.sun.mail.jakarta.mail.jar
-
-
Modify your
portal-ext.propertiesaccordingly:-
Include the package:
org.apache.naming.javain themodule.framework.properties.org.osgi.framework.bootdelegationportal property. -
If you already have customizations for this property, you would include the package in your customized property.
-
If not, you can copy and modify the default property from your current Liferay version's portal.properties file. As an example, for 2025.Q1.3:
module.framework.properties.org.osgi.framework.bootdelegation=\ __redirected,\ com.liferay.expando.kernel.model,\ com.liferay.glowroot.plugin.*,\ com.liferay.portal.servlet.delegate,\ com.liferay.portal.servlet.delegate*,\ com.sun.ccpp,\ com.sun.ccpp.*,\ com.sun.crypto.*,\ com.sun.image.*,\ com.sun.imageio.plugins.*,\ com.sun.jmx.*,\ com.sun.jndi.*,\ com.sun.mail.*,\ com.sun.management.*,\ com.sun.media.*,\ com.sun.msv.*,\ com.sun.org.*,\ com.sun.tools.*,\ com.sun.xml.*,\ com.yourkit.*,\ jdk.*,\ org.apache.el,\ org.apache.el.*,\ org.apache.naming.java,\ org.glowroot.agent,\ org.glowroot.agent.*,\ sun.*,\ weblogic.jndi,\ weblogic.jndi.*Note: The package
org.apache.naming.javais now included in the list
-
-
Start Liferay.
You can validate the fix by performing an action that generates an email, such as triggering an account validation email by logging in as a new user.
Additional Information
The above workaround solution assumes that steps similar to the following were used to configure the JNDI mail session in Tomcat:
-
This configuration or similar within Tomcat's
server.xmlfile:<Resource name="mail/MailSession" auth="Container" type="javax.mail.Session" mail.smtp.host="localhost" mail.smtp.port="25"/> -
This resource configuration within the
LIFERAY_HOME/tomcat/conf/Catalina/localhost/ROOT.xmlfile:<ResourceLink global="mail/MailSession" name="mail/MailSession" type="javax.mail.Session"/> -
The following lines within the
portal-ext.propertiesfile:mail.session.jndi.name=mail/MailSession mail.session.mail=false