Question

For web application running on Tomcat we specify Resource entries in context.xml file. But I couldn't find one under my projects META-INF folder.

If we need to create it manually, could someone point me to a sample.

Was it helpful?

Solution

I got this problem on my project but I only had the folder WEB-INF and was getting errors from the server. What solved for me was:

Created the META-INF folder on the same level as the WEB-INF and put the context.xml there. If you have the META-INF folder, certify that it is right beside the WEB-INF and just put the context.xml there.

The folder structure would be something like:

src
--- main
----- java
----- webapp
-------- META-INF  --> put context.xml here
-------- WEB-INF

An example of the context.xml should be:

<?xml version="1.0" encoding="UTF-8"?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource name="jdbc/postgres" auth="Container" type="javax.sql.DataSource"
    driverClassName="org.postgresql.Driver" url="jdbc:postgresql://127.0.0.1:5432/dbtest"
    username="user" password="password" maxActive="20" maxIdle="10"
    maxWait="-1" />
</Context>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top