EJB Standalone Client JBoss AS7.1.1

Creating a standalone EJB-client application works like the following.

If you use maven, just include the following dependency:


Then you need a file jboss-ejb-client.properties in your classpath. Here an example:


If you haven’t changed default configuration the username+passwort are added with the add-user script in the bin-folder of your jboss.

In your code you just do the following:

Hashtable<String, String> jndi = new Hashtable<String, String>();
jndi.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");		
Context context = new InitialContext(jndi);

String viewClassName = MyInterface.class.getName();
String ejbPath = "ejb:" + appName + "/" + moduleName + "/"
 + distinctName + "/" + beanName + "!" + viewClassName;

MyInterface c = context.lookup(ejbPath);

For further information how to create the ejb-path just have a look at https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI

In short:

  • appName: name of your ear file without ending
  • moduleName: name of your ejb file without ending
  • distinctName: optional name you can set – haven’t used this yet..
  • beanName: the simplename of your bean class
  • viewClassName: the full quallified name of your remote interface

e.g. ejb:/test/test-ejb-1.0.0/TestBean!full.qual.MyInterface


Leave a Comment