1

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.

ArunM
  • 2,274
  • 3
  • 25
  • 47
  • quick guess: Capitalization in filenames? MyApp.XML vs MyApp.xml? I've seen tomcat being case-sensitive even on Windows. In case you're on windows, renaming will be hard - you'll have to go via a different name because Explorer will believe that you still have the same name if all you enter is a different case and refuse to rename. – Olaf Kock May 08 '16 at 10:45
  • Unfortunately No. That was a typo from my side as I have renamed the file names. The case is matching. – ArunM May 08 '16 at 10:51
  • Have you checked file permissions? – Arnaud Kleinveld May 08 '16 at 14:03
  • Possibile duplicate of http://stackoverflow.com/questions/11516747/cannot-create-jdbc-driver-of-class-for-connect-url-null-i-do-not and of http://stackoverflow.com/questions/9332276/cannot-create-jdbc-driver-of-class-for-connect-url-null-tomcat-sql-serv – Pino May 08 '16 at 16:07

0 Answers0