how to write jndi.properties for Websphere 8.5 when creating a EJB 2.1 project by eclipse Luna

551 views Asked by At

I saw an example of jndi.properties file for JBoss Server

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

What changes should I make here so that it works for Websphere 8.5 ?

I am using this tutorial for reference

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

1

There are 1 answers

0
Palamino On

Here is a snippet of code with the properties that work in my Websphere 8.5 environment:

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);