[英]Tomcat Context and JDBC… what am I doing wrong?
So I have a context.xml file placed under my META-INF. 所以我在我的META-INF下放置了一个context.xml文件。 There is only one context.xml file.
只有一个context.xml文件。
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. 我的问题:当我使用
jdbc/myDataSource
将条目从InitialContext中jdbc/myDataSource
,出现了非常常见的“名称jdbc在此Context中未绑定”异常。 How can I set up my Context/Tomcat to successfully return my DataSourceFactory when someone tries to fetch it out of InitialContext using jdbc/myDataSource
? 当有人尝试使用
jdbc/myDataSource
从InitialContext中获取它时,如何设置Context / Tomcat以成功返回DataSourceFactory?
Note: I don't have control over how the DataSourceFactory is being fetched. 注意:我无法控制如何获取DataSourceFactory。 Also, I verified that I can access the datasource via
java:comp/env/jdbc/myDataSource
. 另外,我验证了可以通过
java:comp/env/jdbc/myDataSource
访问数据源。
The Context entry in context.xml the file looks like this: 该文件的context.xml中的Context条目如下所示:
<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: 我的web.xml中的条目是这样的:
<resource-ref>
<res-ref-name>jdbc/myDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
尝试java:/ jdbc / myDataSource
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.