0
votes

My Tomcat 8.0 installation fails to create a datasource using an OracleDataSourceFactory. The logging from Tomcat is not very useful:

NE: 52102734 Public Enter: ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,factoryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shareable},{type=auth,content=Container},{type=singleton,content=true},{type=factory,content=oracle.jdbc.pool.OracleDataSourceFactory},{type=password,content=mypass},{type=maxIdle,content=10},{type=driverClassName,content=oracle.jdbc.OracleDriver},{type=maxWait,content=-1},{type=url,content=myUrl},{type=maxActive,content=30},{type=username,content=myUser}], DAFDataSource, org.apache.naming.NamingContext@3541cb24, {} Jun 24, 2016 10:24:27 AM oracle.jdbc.pool.OracleDataSourceFactory getObjectInstance FINE: 52102734 Return: null Jun 24, 2016 10:24:27 AM oracle.jdbc.pool.OracleDataSourceFactory getObjectInstance

When I try to create an OracleDataSource in my code with the same settings, I am correctly able to retrieve a connection. What is wrong with my factory configuration?

1

1 Answers

0
votes

There are multiple reasons why this was happened:

  • OracleDataSourceFactory returns null if the type of the resource defined in server.xml is javax.sql.DataSource. I had to change it to oracle.jdbc.pool.OracleConnectionPoolDataSource

  • The username and password properties of the resource ignored when specifying the url with JDBC Oracle thin driver