我在WebSphere中定義了一個名爲'jdbc/dataSource1'的JDBC數據源。
在我的基於Spring的應用程序中,我想使用jndi查找獲取數據源,但是使用其他名稱,如'jdbc/dataSource2'。
爲了實現這一點,我創建IBM的Web-bnd.xml文件,其中i的定義的連接如下:數據源自動綁定
<resource-ref binding-name="jdbc/dataSource2" name="jdbc/dataSource1"/>
此外,我在web.xml文件中定義的數據源如下:
<resource-ref>
<description>some awesome datasource</description>
<res-ref-name>jdbc/dataSource2</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
該解決方案僅在使用IBM Web Console進行部署時起作用。當我使用wsadmin工具嘗試部署使用自定義Jython腳本,我得到以下錯誤:
ADMA0007E: A Validation error occurred in task Mapping resource references to re
sources. The Java Naming and Directory Interface (JNDI) name is not specified f
or reference binding jdbc/dataSource2 in module <application_name>.war"
在wsadmin腳本來我使用AdminApp.install(path_to_ear,期權),其中選擇變量只包含關於虛擬主機的選擇映射。
所以問題是我該怎麼做,所以WebSphere將從ibm-web-bnd.xml文件中獲取數據源映射選項?
http://stackoverflow.com/questions/ 19096482/binding-container-managed-authentication-alias-with-datasource-using-jython-scri – 2014-08-30 14:23:40