We have a context file placed in the location CATALINA_BASE/conf/localhost/MyApp.xml.
Content of MyApp.XML is as follows.
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/MyApp">>
<Resource
auth="Container"
driverClassName="oracle.jdbc.OracleDriver"
name="jdbc/MyApp_local"
password="XXXX"
type="javax.sql.DataSource"
url="XXXX"
username="XXX"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
initialSize="10"
maxWait="-1"
maxActive="55"
maxIdle="21"
minIdle="13"
timeBetweenEvictionRunsMillis="34000"
minEvictableIdleTimeMillis="55000"
validationQuery="SELECT 1"
validationInterval="34"
testOnBorrow="true"
removeAbandoned="true"
removeAbandonedTimeout="233"
/>
<Resource
auth="Container"
driverClassName="oracle.jdbc.OracleDriver"
name="jdbc/MyApp_local_du"
password="XXX"
username="XXXX"
type="javax.sql.DataSource"
url="XXX"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
initialSize="5"
maxWait="-1"
maxActive="55"
maxIdle="21"
minIdle="13"
timeBetweenEvictionRunsMillis="34000"
minEvictableIdleTimeMillis="55000"
validationQuery="SELECT 1"
validationInterval="34"
testOnBorrow="true"
removeAbandoned="true"
removeAbandonedTimeout="233"
/>
</Context>
The was file has been copied to CATALINA_BASE/webapps/MyApp.war
The datasource is not being created correctly when the application is being started up as I can see in the logs the following error.
... 33 common frames omitted
Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452) ~[tomcat-dbcp.jar:7.0.55]
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371) ~[tomcat-dbcp.jar:7.0.55]
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) ~[tomcat-dbcp.jar:7.0.55]
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:70) ~[hibernate-entitymanager-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:292) ~[hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:214) ~[hibernate-core-4.2.7.Final.jar:4.2.7.Final]
... 38 common frames omitted
I believe the JNDI is not being resolved properly by the application. Strangely I do not get this error in my local tomcat. The problem is present only when deployed to a unix environment. Any idea why the context is not being detected.