林具有麻煩映射的Weblogic(12c)的定義JNDI數據源到本地JNDI名稱。映射的NameNotFoundException JNDI數據源到本地名稱
我在定義爲「mysqltestds」的WebLogic MySQL的數據源數據源,我想在Web應用程序中映射我到本地名「localds」
我的web.xml性能
<resource-ref>
<res-ref-name>localds</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
與weblogic.xml中
<weblogic-web-app>
<resource-description>
<res-ref-name>localds</res-ref-name>
<jndi-name>mysqltestds</jndi-name>lls
</resource-description>
</weblogic-web-app>
當我使用全局名稱獲得數據源「mysqltestds」它工作正常。
Context initialContext = new InitialContext();
Object resource = initialContext.lookup("mysqltestds");
dataSource = (DataSource) resource;
然而,當我嘗試 「localds」 失敗,出現錯誤:
Context initialContext = new InitialContext();
Object resource = initialContext.lookup("localds");
dataSource = (DataSource) resource;
能javax.naming.NameNotFoundException: Unable to resolve 'localds'. Resolved ''; remaining name 'localds'
任何人的幫助。我按照這個stackoverflow問題Tomcat vs Weblogic JNDI Lookup的方向,但我沒有取得任何成功。
我知道它的展開,因爲如果我使用WebLogic JNDI名稱(「mysqltestds」),它的工作原理,這是有用的。另外,我可以在JNDI查看器中看到它。 – Dunderklumpen 2012-07-18 01:15:59