我试图在Liberty Profile中运行现有的WebSphere应用程序,但遇到了问题。该应用程序具有在服务器中配置的资源环境条目,我需要将其转换为Liberty Profile资源。我如何在server.xml中配置JNDI资源,它不是数据源(dataSource)或常量(jndiEntry)?在Liberty Profile中配置非数据源的JNDI资源
非常感谢
我试图在Liberty Profile中运行现有的WebSphere应用程序,但遇到了问题。该应用程序具有在服务器中配置的资源环境条目,我需要将其转换为Liberty Profile资源。我如何在server.xml中配置JNDI资源,它不是数据源(dataSource)或常量(jndiEntry)?在Liberty Profile中配置非数据源的JNDI资源
非常感谢
您可以使用server.xml中的元素进行配置。这在infocenter中有记录。本质上,你可以使用下面的命令启用server.xml中的jndi功能:
<featureManager>
<feature>jndi-1.0</feature>
</featureManager>
然后你可以配置JNDI条目。你只能用这个做简单的类型,所以没有复杂的对象。要配置您的输入你再这样做:
<jndiEntry jndiName="myProp/philosopher" value="plato" />
的自由轮廓确实类型推断,因此,如果您表示这样的:
<jndiEntry jndiName="myProp/philosopher" value="1234" />
你从JNDI的号码。如果你这样表达:
<jndiEntry jndiName="myProp/philosopher" value="1234.3D" />
你得到一个双。
如果你想一个数字作为一个字符串文字,你会用引号表达出来:
<jndiEntry jndiName="myProp/philosopher" value='"1234.3D"' />
为了得到这个从你的应用程序,你可以做一个全局查找,如:
Context ctx = new InitialContext();
Object jndiConstant = ctx.lookup("myProp/philosopher");
String philosopher = (String) jndiConstant;
你也可以将其映射到ibm-web-bnd.xml文件中的资源环境条目:
<env-entry name="philosopher" binding-name="myProp/philosopher" />
然后使用以下代码查看它:
Context ctx = new InitialContext();
Object jndiConstant = ctx.lookup("java:comp/env/philosopher");
String philosopher = (String) jndiConstant;
目前,这对于Liberty Profile是不可能的。 IBM WasDev论坛回答了此问题https://developer.ibm.com/answers/questions/6221/resource-environment-entries-in-liberty-profile/?community=wasdev 已创建一个RFE流程(31525),以便在将来的版本中支持该流程。
在8.5.5.x有几个新entries:
例如:要配置URL可以使用jndiURLEntry
这是一个好信息,但OP说:“[不]数据源( dataSource)或常量(jndiEntry)“。 –