gpt4 book ai didi

websphere - JNDI 查找在 Liberty Profile 上失败

转载 作者:行者123 更新时间:2023-12-01 03:38:58 26 4
gpt4 key购买 nike

我在 IBM J9 VM 版本 pxa6470sr1-20120330_01 (SR1) (en_US) 上使用 Liberty Profile v8.5.5.5(WebSphere Application Server 8.5.5.5/wlp-1.0.8.cl50520150221-0034)

我安装了 jndi 功能...但无论我做什么,我都无法进行简单的 JNDI 查找。

在我的 server.xml 中

<jndiEntry jndiName="schoolOfAthens/defaultAdminUserName" value="plato" />

我的代码......(这只是几行的servlet)
Object jndiConstant = new InitialContext().lookup(
"schoolOfAthens/defaultAdminUserName");

但这失败了:

javax.naming.NameNotFoundException:在上下文“serverlocal:CELLROOT/SERVERROOT”中找不到名称 schoolOfAthens。

代码直接取自一个示例。

有任何想法吗?

我在本地运行它,也尝试过我的 Bluemix 帐户......结果相同

最佳答案

好的,让这个工作。我在 web.xml 中添加了一个资源引用,并像这样查找:

 Object obj2 = ctx.lookup("java:comp/env/schoolOfAthens/defaultAdminUserName");`

网页.xml
 <resource-ref>
<description>Test Reference</description>
<res-ref-name>schoolOfAthens/defaultAdminUserName</res-ref-name>
<res-auth>Container</res-auth>
</resource-ref>

关于websphere - JNDI 查找在 Liberty Profile 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32252905/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com