林具有麻烦映射的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