Glassfish中的JNDI配置/查找 [英] JNDI configuration/lookup in Glassfish
问题描述
我无法在Glassfish中获得一些基本的JNDI配置。
I'm having trouble getting some basic JNDI configuration going in Glassfish.
我认为应该是一个简单的任务:在运行时,确定某个特定属性是否设置为true。我认为这是JNDI的一个很好的应用程序,但似乎无法在app服务器和我的servlet代码之间获得正确的路径。
I have what I think ought to be a simple task: at run time, determine if a particular property is set to true or not. I think this is a good application of JNDI, but can't seem to get the path correct between the app server and my servlet code.
以下是我如何配置Glassfish的房产:
Here's how I have configured the property in Glassfish:
在我的servlet代码中,我试图通过以下方式查找值:
In my servlet code, I'm trying to look up the value with:
Boolean enabled = (Boolean) ctx.lookup("java:global/arizona/quartz_enabled");
除了这条路径,我还尝试了以下方法但没有成功:
In addition to this path, I've also tried the following without success:
- java:global / arizona / arizona / quartz_enabled
- java:module / arizona / quartz_enabled
- java:module / arizona / arizona / quartz_enabled
我的应用名为arizona,但部署到根目录上下文,如果这很重要。
My app is named "arizona", but deployed to the root context, if that matters.
我确定这只是一个简单的问题,找出适当的命名空间到达该物业,但我觉得我只是拍摄在黑暗中试图找到它。有没有一种简单的方法来浏览Glassfish中的JNDI树?
I'm sure it's just a simple matter of figuring out the proper namespace to reach the property, but I feel like I'm just shooting in the dark trying to find it. Is there a simple way to browse the JNDI tree in Glassfish?
推荐答案
查找服务器中创建的JNDI资源时,它是JNDI名称正是您在服务器上输入的名称。 IE:
When looking up a JNDI resource created in the server, it's JNDI name is exactly what you entered as the name on the server. IE:
布尔启用=(布尔)ctx.lookup(arizona);
Boolean enabled = (Boolean)ctx.lookup("arizona");
关于约定JNDI名称和一些关于如何查看所有内容的示例代码请参阅此页面:
For conventions on JNDI names and some example code on how to look everything up see this page:
http://www.javaworld.com/javaworld/jw-01-2000/jw-01-howto.html
这篇关于Glassfish中的JNDI配置/查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!