You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kevin Huntly <km...@gmail.com> on 2023/03/23 15:38:19 UTC

javax.naming.NamingException: Could not create resource instance

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
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804)
~[spring-beans-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
~[spring-beans-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
~[spring-beans-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
~[spring-beans-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
~[spring-beans-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
~[spring-beans-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
~[spring-beans-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:936)
~[spring-beans-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
~[spring-context-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
~[spring-context-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:702)
~[spring-webmvc-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:668)
~[spring-webmvc-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:716)
~[spring-webmvc-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:591)
~[spring-webmvc-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:530)
~[spring-webmvc-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:170)
~[spring-webmvc-5.3.24.jar:5.3.24-migrated-1.0.6]
        at jakarta.servlet.GenericServlet.init(GenericServlet.java:158)
~[servlet-api.jar:6.0]
        at jakarta.servlet.http.HttpServlet.init(HttpServlet.java:125)
~[servlet-api.jar:6.0]
        at
org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:944)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:901)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:805)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4632)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4919)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:683)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:658)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:713)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:975)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1949)
~[catalina.jar:10.1.7]
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[?:?]
        at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
~[tomcat-util.jar:10.1.7]
        at
java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123)
~[?:?]
        at
org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:776)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:426)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1656)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:898)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:846)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
~[catalina.jar:10.1.7]
        at java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[?:?]
        at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
~[tomcat-util.jar:10.1.7]
        at
java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
~[?:?]
        at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:871)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:241)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:428)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:913)
~[catalina.jar:10.1.7]
        at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
~[catalina.jar:10.1.7]
        at org.apache.catalina.startup.Catalina.start(Catalina.java:795)
~[catalina.jar:10.1.7]
        at
jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:578) ~[?:?]
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:347)
~[bootstrap.jar:10.1.7]
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:478)
~[bootstrap.jar:10.1.7]
Caused by: javax.naming.NamingException: Could not create resource instance
        at
org.apache.naming.factory.FactoryBase.getObjectInstance(FactoryBase.java:98)
~[catalina.jar:10.1.7]
        at
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:342)
~[?:?]
        at org.apache.naming.NamingContext.lookup(NamingContext.java:864)
~[catalina.jar:10.1.7]
        at org.apache.naming.NamingContext.lookup(NamingContext.java:158)
~[catalina.jar:10.1.7]
        at org.apache.naming.NamingContext.lookup(NamingContext.java:850)
~[catalina.jar:10.1.7]
        at org.apache.naming.NamingContext.lookup(NamingContext.java:158)
~[catalina.jar:10.1.7]
        at org.apache.naming.NamingContext.lookup(NamingContext.java:850)
~[catalina.jar:10.1.7]
        at org.apache.naming.NamingContext.lookup(NamingContext.java:158)
~[catalina.jar:10.1.7]
        at org.apache.naming.NamingContext.lookup(NamingContext.java:850)
~[catalina.jar:10.1.7]
        at org.apache.naming.NamingContext.lookup(NamingContext.java:172)
~[catalina.jar:10.1.7]
        at
org.apache.naming.SelectorContext.lookup(SelectorContext.java:161)
~[catalina.jar:10.1.7]
        at javax.naming.InitialContext.lookup(InitialContext.java:409)
~[?:?]
        at
org.springframework.jndi.JndiTemplate.lambda$lookup$0(JndiTemplate.java:157)
~[spring-context-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:92)
~[spring-context-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:157)
~[spring-context-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
~[spring-context-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:96)
~[spring-context-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:114)
~[spring-context-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:239)
~[spring-context-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:225)
~[spring-context-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
~[spring-beans-5.3.24.jar:5.3.24-migrated-1.0.6]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
~[spring-beans-5.3.24.jar:5.3.24-migrated-1.0.6]
        ... 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:

<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?
________________________________________________

Kevin Huntly
Email: kmhuntly@gmail.com
Cell: 716/424-3311
________________________________________________

-----BEGIN GEEK CODE BLOCK-----
Version: 1.0
GCS/IT d+ s a C++ UL+++$ P+(++) L+++ E---
W+++ N+ o K(+) w--- O- M-- V-- PS+ PE Y(+)
PGP++(+++) t+ 5-- X-- R+ tv+ b++  DI++ D++
G++ e(+) h--- r+++ y+++*
------END GEEK CODE BLOCK------

Re: javax.naming.NamingException: Could not create resource instance

Posted by Konstantin Kolinko <kn...@gmail.com>.
пт, 24 мар. 2023 г. в 03:47, Kevin Huntly <km...@gmail.com>:
>
> Object
> of type [class jakarta.mail.Session] available at JNDI location
> [java:comp/env/mail/MailSession] is not assignable to [jakarta.mail.Session]

Apparently you have two copies of a "jakarta.mail.Session" class,
loaded by different classloaders.

FYI:
https://tomcat.apache.org/tomcat-10.1-doc/class-loader-howto.html

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


Re: javax.naming.NamingException: Could not create resource instance

Posted by Kevin Huntly <km...@gmail.com>.
Okay, I made sure I have the jakarta.mail packages in ${catalina.home}/lib,
I've modified the context.xml from javax.mail.Session to
jakarta.mail.Session and I'm receiving this:

[Time: 23 Mar 2023 20:44:04,203][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 org.springframework.jndi.TypeMismatchNamingException: Object
of type [class jakarta.mail.Session] available at JNDI location
[java:comp/env/mail/MailSession] is not assignable to [jakarta.mail.Session]
[Time: 23 Mar 2023 20:44:04,211][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 org.springframework.jndi.TypeMismatchNamingException: Object
of type [class jakarta.mail.Session] available at JNDI location
[java:comp/env/mail/MailSession] is not assignable to [jakarta.mail.Session]
________________________________________________

Kevin Huntly
Email: kmhuntly@gmail.com
Cell: 716/424-3311
________________________________________________

-----BEGIN GEEK CODE BLOCK-----
Version: 1.0
GCS/IT d+ s a C++ UL+++$ P+(++) L+++ E---
W+++ N+ o K(+) w--- O- M-- V-- PS+ PE Y(+)
PGP++(+++) t+ 5-- X-- R+ tv+ b++  DI++ D++
G++ e(+) h--- r+++ y+++*
------END GEEK CODE BLOCK------


On Thu, Mar 23, 2023 at 8:29 PM Konstantin Kolinko <kn...@gmail.com>
wrote:

> пт, 24 мар. 2023 г. в 03:09, Konstantin Kolinko <kn...@gmail.com>:
> >
> > чт, 23 мар. 2023 г. в 18:38, Kevin Huntly <km...@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),
>
> Regarding Mail API links in the documentation, see
> https://bz.apache.org/bugzilla/show_bug.cgi?id=66542
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: javax.naming.NamingException: Could not create resource instance

Posted by Konstantin Kolinko <kn...@gmail.com>.
пт, 24 мар. 2023 г. в 03:09, Konstantin Kolinko <kn...@gmail.com>:
>
> чт, 23 мар. 2023 г. в 18:38, Kevin Huntly <km...@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),

Regarding Mail API links in the documentation, see
https://bz.apache.org/bugzilla/show_bug.cgi?id=66542

Best regards,
Konstantin Kolinko

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


Re: javax.naming.NamingException: Could not create resource instance

Posted by Konstantin Kolinko <kn...@gmail.com>.
чт, 23 мар. 2023 г. в 18:38, Kevin Huntly <km...@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org