Red Hat Training

A Red Hat training course is available for Red Hat JBoss Enterprise Application Platform

8.8. Reference

8.8.1. EJB JNDI Naming Reference

The JNDI lookup name for a session bean has the syntax of:
If the session bean's JAR file has been deployed within an enterprise archive (EAR) then this is the name of that EAR. By default, the name of an EAR is its filename without the .ear suffix. The application name can also be overridden in its application.xml file. If the session bean is not deployed in an EAR then leave this blank.
The module name is the name of the JAR file that the session bean is deployed in. By the default, the name of the JAR file is its filename without the .jar suffix. The module name can also be overridden in the JAR's ejb-jar.xml file.
JBoss EAP 6 allows each deployment to specify an optional distinct name. If the deployment does not have a distinct name then leave this blank.
The bean name is the classname of the session bean to be invoked.
The view class name is the fully qualified classname of the remote interface. This includes the package name of the interface.
The ?stateful suffix is required when the JNDI name refers to a stateful session bean. It is not included for other bean types.

8.8.2. EJB Reference Resolution

This section covers how JBoss implements @EJB and @Resource. Please note that XML always overrides annotations but the same rules apply.

Rules for the @EJB annotation

  • The @EJB annotation also has a mappedName() attribute. The specification leaves this as vendor specific metadata, but JBoss recognizes mappedName() as the global JNDI name of the EJB you are referencing. If you have specified a mappedName(), then all other attributes are ignored and this global JNDI name is used for binding.
  • If you specify @EJB with no attributes defined:
    ProcessPayment myEjbref;
    Then the following rules apply:
    • The EJB jar of the referencing bean is searched for an EJB with the interface used in the @EJB injection. If there are more than one EJB that publishes same business interface, then an exception is thrown. If there is only one bean with that interface then that one is used.
    • Search the EAR for EJBs that publish that interface. If there are duplicates, then an exception is thrown. Otherwise the matching bean is returned.
    • Search globally in JBoss runtime for an EJB of that interface. Again, if duplicates are found, an exception is thrown.
  • @EJB.beanName() corresponds to <ejb-link>. If the beanName() is defined, then use the same algorithm as @EJB with no attributes defined except use the beanName() as a key in the search. An exception to this rule is if you use the ejb-link '#' syntax. The '#' syntax allows you to put a relative path to a jar in the EAR where the EJB you are referencing is located. Refer to the EJB 3.1 specification for more details.

8.8.3. Project dependencies for Remote EJB Clients

Maven projects that include the invocation of session beans from remote clients require the following dependencies from the JBoss EAP 6 Maven repository.

Table 8.4. Maven dependencies for Remote EJB Clients

GroupID ArtifactID
org.jboss.spec jboss-javaee-6.0 jboss-as-ejb-client-bom
org.jboss.spec.javax.transaction jboss-transaction-api_1.1_spec
org.jboss.spec.javax.ejb jboss-ejb-api_3.1_spec
org.jboss jboss-ejb-client
org.jboss.xnio xnio-api
org.jboss.xnio xnio-nio
org.jboss.remoting3 jboss-remoting
org.jboss.sasl jboss-sasl
org.jboss.marshalling jboss-marshalling-river
With the exception of jboss-javaee-6.0 and jboss-as-ejb-client-bom, these dependencies must be added to the <dependencies> section of the pom.xml file.
The jboss-javaee-6.0 and jboss-as-ejb-client-bom dependencies should be added to the <dependencyManagement> section of your pom.xml with the scope of import.


The artifactID's versions are subject to change. Refer to the Maven repository for the relevant version.

Refer to ejb-remote/client/pom.xml in the quickstart files for a complete example of dependency configuration for remote session bean invocation.

8.8.4. jboss-ejb3.xml Deployment Descriptor Reference

jboss-ejb3.xml is a custom deployment descriptor that can be used in either EJB JAR or WAR archives. In an EJB JAR archive it must be located in the META-INF/ directory. In a WAR archive it must be located in the WEB-INF/ directory.
The format is similar to ejb-jar.xml, using some of the same namespaces and providing some other additional namespaces. The contents of jboss-ejb3.xml are merged with the contents of ejb-jar.xml, with the jboss-ejb3.xml items taking precedence.
This document only covers the additional non-standard namespaces used by jboss-ejb3.xml. Refer to for documentation on the standard namespaces.
The root namespace is

Assembly descriptor namespaces

The following namespaces can all be used in the <assembly-descriptor> element. They can be used to apply their configuration to a single bean, or to all beans in the deployment by using * as the ejb-name.
The clustering namespace: urn:clustering:1.0
This allows you to mark EJB's as clustered. It is the deployment descriptor equivalent to @org.jboss.ejb3.annotation.Clustered.
The security namespace (urn:security)
This allows you to set the security-domain and the run-as-principal for an EJB.
The resource adapter namespace: urn:resource-adapter-binding
This allows you to set the resource adapter for a Message-Driven Bean.
The IIOP namespace: urn:iiop
The IIOP namespace is where IIOP settings are configured.
The pool namespace: urn:ejb-pool:1.0
This allows you to select the pool that is used by the included stateless session beans or Message-Driven Beans. Pools are defined in the server configuration.
The cache namespace: urn:ejb-cache:1.0
This allows you to select the cache that is used by the included stateful session beans. Caches are defined in the server configuration.

Example 8.8. jboss-ejb3.xml file

<?xml version="1.1" encoding="UTF-8"?>
<jboss:ejb-jar xmlns:jboss=""
    version="3.1" impl-version="2.0">


There are known issues with the jboss-ejb3-spec-2_0.xsd that may result in schema validation errors. You can ignore these errors. For more information, see