I\'m using JBoss Server for EJB And I need JNDI in console app to get reference of session bean, console app code looks like this
import java.util.Properties
To overcome above error you need to pay attention to two points.
First , You need to have jboss-client.jar in classpath.
Second, according to Jboss version you are using you need to change your provider url.
For JBossAS 5 you should set following properties in environment
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
For JBossAS 7 you should set following properties in environment
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, "remote://localhost:4447"));
env.put(Context.SECURITY_PRINCIPAL, System.getProperty("username", DEFAULT_USERNAME));
env.put(Context.SECURITY_CREDENTIALS, System.getProperty("password", DEFAULT_PASSWORD));