Trying to expose an Oracle connection through tomcat Context.xml, I get a NamingException. I've followed several tutorials, but I'm still getting the exception. Help!
Java:
String environmentLookup = "java:comp/env/jdbc/ENTERPRISE_DATABASE";
OracleDataSource ods = InitialContext.doLookup(environmentLookup);
Connection connection = ods.getConnection();
App's web.xml:
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/ENTERPRISE_DATABASE</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
Tomcat's context.xml:
<Resource name="jdbc/ENTERPRISE_DATABASE" auth="Container"
type="javax.sql.Datasource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@enterprise.db.company.com:1524:schema1234"
username="ENTERPRISE_USER" password="ENTERPRISE_PASSWORD" maxActive="20"
maxIdle="10" maxWait="-1" />
The Exception:
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:144)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.apache.naming.NamingContext.lookup(NamingContext.java:842)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
type="javax.sql.Datasource"
Should be
type="javax.sql.DataSource"