TheSpaceboy0
TheSpaceboy0

Reputation: 95

tomcat7 doesn't read context xml file

I would like to specify context for db in xml file.

  <Context path="/db3" docBase="C:/my/workspace/db3/">

 <Resource name="jdbc/ksidb" auth="Container" 
        type="javax.sql.DataSource"
        description="Books" 
        driverClassName="com.mysql.jdbc.Driver"
        url="jdbc:mysql://localhost:3306/ksidb"
        username="root"
        password="root"
        maxActive="20" /> 
</Context>

I've read that I should copy that file to /webapps tomcat catalogoue. I did this but tomcat7 doesn't read the file. Do you know why? What to do? Thx.

Upvotes: 0

Views: 754

Answers (1)

Ryan Stewart
Ryan Stewart

Reputation: 128949

What you read is wrong. I'd question other advice from that source if it told you something so completely false. Per the Tomcat docs, your options for placing the context configuration are as follows:

  • In an individual file at /META-INF/context.xml inside the application files. Optionally (based on the Host's copyXML attribute) this may be copied to $CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to application's base file name plus a ".xml" extension.
  • In individual files (with a ".xml" extension) in the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory. The context path and version will be derived from the base name of the file (the file name less the .xml extension). This file will always take precedence over any context.xml file packaged in the web application's META-INF directory.
  • Inside a Host element in the main conf/server.xml.

I highly recommend you visit the linked docs to learn more about the correct way to configure Tomcat.

Upvotes: 1

Related Questions