I'm struggling to configure a simple JNDI pooled datasource in Tomcat 6.0.32.
I want to create the datasource definition outside my web application artifact. Basically I don't want my application to know the credentials to access the database server. I was under the assumption that, like in Weblogic, it should be possible to create a "global" JNDI datasource in Tomcat, but so far I have been unsuccessful.
I have tried to add the datasource definition in CATALINA_HOME/conf/context:
<Resource name="jdbc/mydb"
auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
factory="oracle.jdbc.pool.OracleDataSourceFactory"
url="jdbc:oracle:thin:@1.1.1.1.:xxx"
user="xxxx"
password="yyyy"/>
The result is that the server outputs the following line, when booting:
SEVERE: Null component Catalina:type=DataSource,path=/,host=localhost,class=javax.sql.DataSource,name="jdbc/mydb"
Any pointer would be appreciated.
Move your data source configuration to server.xml <GlobalNamingResources>
. (And don't forget to add the driver jar file to tomcat lib).
Configure your context.xml so that all Application are aware of the global resource.
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<ResourceLink global="jdbc/mydb" name="jdbc/mydb" type="javax.sql.DataSource"/>
</Context>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With