How to run EJB 2 with JBoss / WildFly ?

EJB 2 Entity beans have been marked as optional since JAVA EE 7. This means that each vendor can opt to include them or not.
As far as WildFly / JBoss EAP 7 is concerned, EJB Entity Beans are no longer supported. This means Container Managed Persistence (CMP) and Bean Managed Persistence (BMP) entity beans must be rewritten to use Java Persistence API (JPA) entities when you migrate to JBoss EAP 7. EJB 2 Session Beans and Message Drive Beans (MDB) are still available.

The recommended approach is to migrate the EJB2 Stateful Session Beans (SFSB), Stateless Session Beans (SLSB), Message Driven Beans (MDB) to EJB 3, and for the Container-Managed Persistence (CMP) and Bean-Managed Persistence (BMP) Entity Beans to use the Java Persistence API (JPA) according to the EJB 3 specification.

Calling an EJB 2 from an EJB 3

Let’s see an example how you can call an EJB 2 Session Bean from an EJB 3 equivalent Session Bean:

{@EJB(name = "injected/Stateless2", mappedName = "Stateless2")})
public class Stateless3Bean

In the above example, the name parameter for the @EJB specifies the name with which the 2.1 EJB will be bound in the ENC (java:comp/env) namespace of the Stateless3Bean. The mapped-name parameter specifies the global JNDI binding of the 2.1 EJB.

Running EJB 2 CMP with JBoss EAP 6

If you are running JBoss EAP 6 / JBoss AS 7 you can make some changes in your configuration to run CMP with JBoss EAP 6.
Firstly, you need to include the the extension module in your “full” configuration profile:

    <extension module=""/>

Then, include also the cmp subsystem:

    <subsystem xmlns="urn:jboss:domain:cmp:1.1"/>

Besides it, there are known limitations you need to be aware of (Container Configuration Is No Longer Supported, Server Side Interceptor Configuration, deprecation of the jboss.xml Deployment Descriptor File) which are discussed in detail here: