JNDI configuration/lookup in Glassfish

非 Y 不嫁゛ 提交于 2019-12-04 04:31:53

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:

Boolean enabled = (Boolean)ctx.lookup("arizona");

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

In similar situations, I simply place a breakpoint where object (InitialContext in this case) is instantiated and evaluate it afterwards. IntelliJ IDEA has nice evaluator, not sure about other, arguably inferior, IDEs.

Btw, the correct prefix for all Java EE bindings is java:comp/env/, e.g. java:comp/env/arizona/quartz_enabled.

You might also want to look at this resource.

I can't make it work with javax.naming.InitialContext#lookup but injecting resource with

@Resource(name = "arizona/quartz_enabled")
private Boolean enabled;

works just fine.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!