@@ -144,7 +144,7 @@ protected TomcatWebServer getTomcatWebServer(Tomcat tomcat)
144144 addExtraContextResources (contextProperties , context );
145145
146146 // Add the SMTP config
147- context . getNamingResources (). addResource ( getMailResource () );
147+ addSmtpProperties ( context );
148148
149149 // Add the encryption key(s)
150150 context .addParameter ("EncryptionKey" , contextProperties .getEncryptionKey ());
@@ -373,39 +373,34 @@ private String getPropValue(Map<Integer, String> propValues, Integer resourceKey
373373 return val != null && !val .isBlank () ? val .trim () : defaultValue ;
374374 }
375375
376- private ContextResource getMailResource ( )
376+ private void addSmtpProperties ( StandardContext context )
377377 {
378378 // Get session/mail properties
379379 LabKeyServer .MailProperties mailProps = _server .smtpSource ();
380- ContextResource mailResource = new ContextResource ();
381- mailResource .setName ("mail/Session" );
382- mailResource .setAuth ("Container" );
383- mailResource .setType ("jakarta.mail.Session" );
384- mailResource .setProperty ("mail.smtp.host" , mailProps .getSmtpHost ());
385- mailResource .setProperty ("mail.smtp.user" , mailProps .getSmtpUser ());
386- mailResource .setProperty ("mail.smtp.port" , mailProps .getSmtpPort ());
380+
381+ context .addParameter ("mail.smtp.host" , mailProps .getSmtpHost ());
382+ context .addParameter ("mail.smtp.user" , mailProps .getSmtpUser ());
383+ context .addParameter ("mail.smtp.port" , mailProps .getSmtpPort ());
387384
388385 if (mailProps .getSmtpFrom () != null )
389386 {
390- mailResource . setProperty ("mail.smtp.from" , mailProps .getSmtpFrom ());
387+ context . addParameter ("mail.smtp.from" , mailProps .getSmtpFrom ());
391388 }
392389 if (mailProps .getSmtpPassword () != null )
393390 {
394- mailResource . setProperty ("mail.smtp.password" , mailProps .getSmtpPassword ());
391+ context . addParameter ("mail.smtp.password" , mailProps .getSmtpPassword ());
395392 }
396393 if (mailProps .getSmtpStartTlsEnable () != null )
397394 {
398- mailResource . setProperty ("mail.smtp.starttls.enable" , mailProps .getSmtpStartTlsEnable ());
395+ context . addParameter ("mail.smtp.starttls.enable" , mailProps .getSmtpStartTlsEnable ());
399396 }
400397 if (mailProps .getSmtpSocketFactoryClass () != null )
401398 {
402- mailResource . setProperty ("mail.smtp.socketFactory.class" , mailProps .getSmtpSocketFactoryClass ());
399+ context . addParameter ("mail.smtp.socketFactory.class" , mailProps .getSmtpSocketFactoryClass ());
403400 }
404401 if (mailProps .getSmtpAuth () != null )
405402 {
406- mailResource . setProperty ("mail.smtp.auth" , mailProps .getSmtpAuth ());
403+ context . addParameter ("mail.smtp.auth" , mailProps .getSmtpAuth ());
407404 }
408-
409- return mailResource ;
410405 }
411406}
0 commit comments