## page was renamed from JNDI = JNDI = JNDI is a standard Java API that is bundled with JDK1.3 and higher. JNDI provides a common interface to a variety of existing naming services: DNS, LDAP, Active Directory, RMI registry, COS registry, NIS, and file systems. http://docs.jboss.org/jbossas/jboss4guide/r1/html/ch3.chapter.html http://stackoverflow.com/questions/13643127/how-does-the-ejb-client-locate-the-ejb-server-without-url == Sample == Properties: * java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory * java.naming.provider.url=jnp://localhost:1099 * java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces File test/Client.java {{{#!highlight java package test; import java.security.Security; import java.util.Properties; import javax.naming.Context; import javax.naming.InitialContext; import org.allowed.bitarus.IWSTest; public class Client { public static void main(String args[]) throws Exception { Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); env.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099"); InitialContext context = new InitialContext(env); IWSTest test = (IWSTest) context.lookup("WSTest/remote"); System.out.println( test.helloWorld() ); } } }}} Build: {{{#!highlight sh cd test #package folder javac -cp .:test2-0.0.1.jar Client.java }}} Run: {{{#!highlight sh java -cp .:/opt/jboss-5.1.0.GA/client/*:test/test2-0.0.1.jar test/Client # JBoss client Jars, EJB with interface IWSTest }}} == Maven sample == Structure {{{ . |-- pom.xml |-- src | `-- main | `-- java | `-- org | `-- allowed | `-- bitarus | `-- ejbclient | `-- Client.java `-- target |-- classes | `-- org | `-- allowed | `-- bitarus | `-- ejbclient | `-- Client.class |-- ejbclient-1.0.jar |-- maven-archiver | `-- pom.properties `-- surefire }}} Content pom.xml {{{#!highlight xml 4.0.0 org.allowed.bitarus ejbclient jar 1.0 ejbclient http://maven.apache.org org.apache.maven.plugins maven-jar-plugin 2.4 org.allowed.bitarus.ejbclient.Client org.allowed.bitarus test2 0.0.1 }}} Content Client.java {{{#!highlight java package org.allowed.bitarus.ejbclient; import java.security.Security; import java.util.Properties; import javax.naming.Context; import javax.naming.InitialContext; import org.allowed.bitarus.IWSTest; public class Client { public static void main(String args[]) throws Exception { Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); env.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099"); InitialContext context = new InitialContext(env); IWSTest test = (IWSTest) context.lookup("WSTest/remote"); System.out.println( test.helloWorld() ); } } }}} Maven steps: {{{#!highlight sh mvn clean compile package }}} Run program: {{{#!highlight sh java -classpath "/opt/jboss-5.1.0.GA/client/*:target/ejbclient-1.0.jar:/tmp/test2/target/test2-0.0.1.jar" org.allowed.bitarus.ejbclient.Client }}}