чт, 23 мар. 2023 г. в 18:38, Kevin Huntly <kmhun...@gmail.com>:
>
> Hi Everyone,
>
> I just migrated one of my apps off javax.servlet and onto jakarta.servlet.
> I am getting the following exception:
>
> <code>
> [Time: 23 Mar 2023 11:31:44,134][Thread: main][Log:
> org.springframework.web.context.support.XmlWebApplicationContext][Level:
> WARN ] - [File: AbstractApplicationContext.java:591] - Exception
> encountered during context initialization - cancelling refresh attempt:
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name 'mailSession': Invocation of init method failed; nested
> exception is javax.naming.NamingException: Could not create resource
> instance
> [Time: 23 Mar 2023 11:31:44,139][Thread: main][Log:
> org.springframework.web.servlet.DispatcherServlet][Level: ERROR] - [File:
> FrameworkServlet.java:534] - Context initialization failed
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name 'mailSession': Invocation of init method failed; nested
> exception is javax.naming.NamingException: Could not create resource
> instance
>         at
> [...]
>         ... 59 more
> </code>
>
> I've never seen this exception before, and the same code/configuration
> works on Tomcat 9.0.73. This is coming from 10.1.7 on RHEL 8.7 with SELinux
> enabled. I know the exception is coming from Spring, but it is definitely
> related to the JNDI configuration for my mailsession.
>
> The base context.xml is largely unchanged, with the exception of this
> addition:

(You say "the base context.xml." If you were editing the default
conf/context.xml file shared by all web applications, instead of the
one that belongs to our own web application, that is a usual
misunderstanding / misconfiguration. Though not relevant to your
error.)

Documentation:
https://tomcat.apache.org/tomcat-10.1-doc/config/context.html#Defining_a_context

> <code>
>     <Resource name="mail/MailSession" auth="Container"
> type="javax.mail.Session" description="E-Mail Resource"
>         mail.debug="true" mail.transport.protocol="smtp"
> mail.smtp.host="localhost" mail.smtp.auth="false" />
> </code>
>
> Anyone have any ideas?

Have you read the docs on configuring the mail session factory?
https://tomcat.apache.org/tomcat-10.1-doc/jndi-resources-howto.html#JavaMail_Sessions

Note that
"4" an implementation library for Mail API is not bundled with Tomcat
(you have to provide the needed library),  Do you have one?

"3" If the documentation is correct, the name of the package in
Jakarta EE is "jakarta.mail.", not "javax.mail." (as used in your
configuration),

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to