Hello, I've following the examples in http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.htmlyo configure a data-source for an Oracle 10g database. In the context configuration section it mention that the resource element must be placed in the Context and the section http://tomcat.apache.org/tomcat-6.0-doc/config/context.html explains that it can be included in the $CATALINA_BASE/conf/context.xml or in the /META-INF/context.xml inside the WAR.
I have placed the resource element in the $CATALINA_BASE/conf/context.xml file so it is copied to all the webapps but the application cannot find the data-source. I placed it on the META-INF/context.xml without removing it from $CATALINA_BASE/conf/context.xml a$CATALINA_BASE/conf/context.xml nd it worked. After that I remove it from the $CATALINA_BASE/conf/context.xml leaving only the configuration in the META-INF/context.xml and it did not work again. I got to have in both META-INF/context.xml and META-INF/context.xml in order for the data source to work. I don't understand why do I have to place the Resource element in both files. ------------------------------------------------------------------------------------------------------------------------- This is my context.xml inside $CATALINA_BASE/conf/. <?xml version='1.0' encoding='utf-8'?> <Context> <WatchedResource>WEB-INF/web.xml</WatchedResource> <Resource name="jdbc/oracleDS" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@oracle:1521:xe" username="x" password="x" maxActive="1000" maxIdle="20" maxWait="200"/> </Context> -------------------------------------------------------------------------------------------------------------------------- This is my context.xml inside META-INF/context.xml. <?xml version="1.0" encoding="UTF-8"?> <Context path="/application_name"> <<Resource auth="Container" driverClassName="oracle.jdbc.OracleDriver" maxActive="1000" maxIdle="20" maxWait="200" name="jdbc/oracleDS" password="x" type="javax.sql.DataSource" url="jdbc:oracle:thin:@oracle:1521:xe" username="x" /> </Context> --------------------------------------------------------------------------------------------------------------------------- The reference in the web.xml. <resource-ref> <description>Oracle DataSource</description> <res-ref-name>jdbc/oracleDS</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>