Tomcat – Name [ ] is not bound in this Context. Unable to find [jdbc] Tomcat Issues

databasejdbctomcat

I just created a fresh Oracle Linux 7 VM with Tomcat 7 and Java 8_40. I've created several servers with Apache and Tomcat before, but never connecting to databases before. SELinux and firewalld are both off (for testing purposes.) I can't seem to get the jdbc configured correctly. Here's what I have:

Context.xml:

<ResourceLink global="jdbc/JCAppsCoreDS" name="jdbc/JCAppsCoreDS" type="javax.sql.DataSource"/>

Server.xml

    <Resource name="jdbc/JCAppsCoreDS" auth="Container"
   type="javax.sql.DataSource"
   driverClassName="oracle.jdbc.OracleDriver"
   url="jdbc:oracle:thin:@//******/PROD"
   username="******" password="*****"
   initialSize="5" maxActive="100" maxIdle="-1" maxWait="30"
   validationQuery="select 1 from dual"
   testOnBorrow="true"
   factory="org.apache.commons.dbcp.BasicDataSourceFactory" />

With the ***** being actual items of course. When I try to go to the URL of my application I get:

Naming exception Error while connecting to the database : javax.naming.NameNotFoundException: Name [jdbc/JCAppsCoreDS] is not bound in this Context. Unable to find [jdbc].

As far as I can tell, my config is correct, but I'm still getting errors. Anybody have any ideas? Also, I don't see much as far as this error goes in the logs. Does anyone know which logs and where I need to increase the log level? I've messed with them a bit, but haven't been able to get more info.

Thanks!

Best Answer

Did you configure the Resource reference in web.xml?

<resource-ref>
  <res-ref-name>jdbc/JCAppsCoreDS</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>