So I have a context.xml file placed under my META-INF. There is only one context.xml file.
My Question:
When I pull the entry out of InitialContext using jdbc/myDataSource
, I'm getting the very common "Name jdbc is not bound in this Context" exception. How can I set up my Context/Tomcat to s开发者_运维问答uccessfully return my DataSourceFactory when someone tries to fetch it out of InitialContext using jdbc/myDataSource
?
Note: I don't have control over how the DataSourceFactory is being fetched.
Also, I verified that I can access the datasource via java:comp/env/jdbc/myDataSource
.
The Context entry in context.xml the file looks like this:
<Context shallowOutput="true" path="/">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource name="jdbc/myDataSource"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
driverClassName="oracle.jdbc.driver.OracleDriver"
username="OMITTED"
password="OMITTED"
url="OMITTED"
maxActive="20"
maxIdle="10"
maxWait="-1"/>
</Context>
The entry in my web.xml is like this:
<resource-ref>
<res-ref-name>jdbc/myDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
try java:/jdbc/myDataSource
精彩评论