使用Websphere在Java中读取环境变量 [英] Read a Environment Variable in Java with Websphere

查看:298
本文介绍了使用Websphere在Java中读取环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Websphere应用服务器7.0(WAS7)和环境变量的阅读有一点问题。

I've a little problem with Websphere application server 7.0 (WAS7) and the reading of Environment Varaibles.

使用TomCat,我已将变量定义为

With TomCat, I've defined a variable as

<Environment name="myVar" type="java.lang.String" value="myVarOnServeur"

我在initialContext上查找了它:

and I read it with a lookup on the initialContext :

Context ctx = new InitialContext();
String myVar = (String) ctx.lookup( "java:comp/env/myVar" );

它确实有效!

但是Websphere,我在GUI上定义了一个环境变量,但我无法在我的java代码中读取它。我有一个NamingException。

But with Websphere, I define a environment variable on the GUI but I can't read it in my java code. I've a NamingException.

http:/ /fullahead.org/work/stackoverflow/was-environment-variables.png

如何解决我的问题呢?

推荐答案

我没有看到任何说明可以通过ctx.lookup(java:comp / env / ...)读取这些条目的内容);

I don't see anything there that says that those entries can be read via ctx.lookup( "java:comp/env/..." );

这篇关于使用Websphere在Java中读取环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆