简体   繁体   中英

JNDI NameNotFoundException after Tomcat 8 upgrade

I upgraded from Tomcat 8.0.18 to 8.0.23 and all of the sudden I have a JNDI issue. I looked at the changelogs, Tomcat 8 Changelogs , and I see three JNDI changes, though none strike me as something that would break a previously working configuration.

JNDI related changes were made for bugs 49785, 57587, and an entry under 8.0.19 under "Other".

I am receiving this exception when I start up Tomcat with 8.0.23:

javax.naming.NameNotFoundException: Name [jdbc/MyCluster] is not bound in this Context. Unable to find [jdbc].

In my web application I have a resource link defined:

<Context>
   <ResourceLink name="jdbc/MyCluster" global="jdbc/MyCluster" auth="Container" type="javax.sql.DataSource" />
</Context>

I have Tomcat configured with:

<Resource name="jdbc/MyCluster" global="jdbc/MyCluster" ......./>

I am stumped... I cannot figure out what makes my code break after my upgrade from 18 to 23 :(

Just in case anyone was curious about how upgrading from Tomcat 8.0.18 to 8.0.24 could really cause JNDI to screw up, the answer lies in ANT.

ANT Copy documentation

Myself and some other engineers had no idea that ANT Copy does nothing if the file you are trying to overwrite has a newer timestamp... who knew copy had such a complicated condition!?! I believe this is why me and multiple people never looked at the documentation, it is such an unexpected behavior.

Anyways, by upgrading to the newer version of Tomcat my context.xml that contained the resourcelink jdbc/MyCluster was failing to overwrite the newer and more recent timestamp of Tomcat's default context.xml! Once the overwrite flag is set to true, JNDI works again :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM