首页 > 解决方案 > eclipse Luna创建EJB 2.1项目时如何为Websphere 8.5编写jndi.properties

问题描述

我看到了 JBoss 服务器的 jndi.properties 文件示例

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost

我应该在此处进行哪些更改以使其适用于 Websphere 8.5?

我正在使用本教程作为参考

https://www.tutorialspoint.com/ejb/ejb_create_application.htm

标签: javaeclipsejbosswebsphereejb-2.x

解决方案


这是一段代码,其中包含在我的 Websphere 8.5 环境中工作的属性:

import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;

Properties p = new Properties();
p.put(Context.PROVIDER_URL, "iiop://localhost:2809");
p.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
p.put("com.ibm.websphere.naming.jndicache.cacheobject", "cleared");

Context context = new InitialContext(p);

推荐阅读