websphere8.0上的web.xml中resource-ref配置问题
最近碰到了一个问题,跟大家分享一下,以避免同样的错误,在websphere上面发布应用时,在web.xml中配置了一个数据源:
<resource-ref>
<res-ref-name>jdbc/testDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
而在websphere的资源池里也有一个同样名称的数据源jdbc/testDB,在发布后会发生<resource-ref>节点以后的节点都读取不到的问题。在进行了n多的测试以后,解决方法如下:
web.xml里的数据源必须要指定一个id,如:
<resource-ref id = "Ref_1234567890">
<res-ref-name>jdbc/testDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
这样的话即使有同名的数据源配置,也不会发生节点读取不到的问题了。