Version 7

    EJB 3.1 Embeddable prototype

    This page reflects the current state of the JBoss EJB 3.1 Embeddable prototype.


    The JBoss EJB 3.1 Embeddable prototype is not JBoss Embedded or the old EJB 3 Embedded. The old EJB 3 Embedded was actually a preview of what could be achieved with JBoss MicroContainer. It is better to think of it as a preview of JBoss AS 5.0. Later on it was renamed to JBoss Embedded.


    Meanwhile for JBoss AS 6 a new JBoss Embedded AS implementation has been made, which enables JBoss AS 6 to be booted within a JVM. Using this facility a new standalone prototype has been created.


    The goal of JBoss EJB 3.1 Embeddable is to have a standalone version of EJB 3 working according to the specifications in EJB 3.1 and fully compatible with the version going into JBoss AS.

    How to use in your project

    You can use jboss-ejb3-embedded-standalone either from Maven or using the jar directly in your favorite IDE/build/test-runner tool.


    To get access to the latest Embeddable artifacts you must enable the JBoss Maven repositories either in your settings.xml or in your pom.xml. As an example I've pasted a pom.xml here:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="" xmlns:xsi=""
             <name>JBoss Public Maven Repository Group</name>
                   <argLine>-Djboss.home=${JBOSS_HOME} -Xmx512m -XX:MaxPermSize=256m -Djava.endorsed.dirs=${JBOSS_HOME}/lib/endorsed</argLine>

    Jar usage

    The jboss-ejb3-embedded-standalone jar is located in $JBOSS_HOME/client/jboss-ejb3-embedded-standalone.jar. Make sure this jar is on your class path when you run your Embeddable EJB test.


    Note that the jar has references to other jars via a Class-Path entry in the manifest. So if you copy it around make sure these are copied (or available) as well. The most important one being javassist.jar because of the way we've implement no-interface views.

    How to use in your code

    Now you can create any kind of session bean in your code and do a test on it using Embeddable.

    public class HelloBeanITCase
       public void test1() throws NamingException
          EJBContainer container = EJBContainer.createEJBContainer();
          // Note that global naming isn't working yet.
          InitialContext ctx = new InitialContext();
          Hello bean = (Hello) ctx.lookup("HelloBean/local");
          String now = new Date().toString();
          String actual = bean.sayHello(now);
          assertEquals("Hello " + now, actual);

    The test above is actually defined as an (Maven) integration test. This is because of the finacle details in class loading of the surefire plugin. So we'll use the failsafe plugin instead.

    How to run your test

    To run your test you need to have a full JBoss AS installation at hand. The standalone embeddable will delegate to JBoss Embedded AS to boot up an AS instance in your JVM.


    1. Make sure either your environment variable JBOSS_HOME or system property jboss.home is setup properly.
    2. Use the following command line '-Xmx512m -XX:MaxPermSize=256m -Djava.endorsed.dirs=$JBOSS_HOME/lib/endorsed'.


    The pom.xml shown previously outlines how this can be achieved using the failsafe plugin. Surefire plugin does class loading trickery to get stuff up and running. This conflicts with the way Embedded works.

    Common Problems

    1. OutOfMemoryError or empty Exception from main thread.
      Because we run the full AS within a JVM you need extra memory. There might even not be enough memory for a proper stack trace.
      Add '-Xmx512m -XX:MaxPermSize=256m' to your command line.
    2. java.lang.NoSuchMethodError: javax.annotation.Resource.lookup()Ljava/lang/String;
      The current JDK comes with an older version of the Common Annotations API (JSR 250). The correct version is distributed with the AS installation. This is controlled with system property java.endorsed.dirs, which is not pointing to $JBOSS_HOME/lib/endorsed. (Note: Intellij has no environment variables replacing, best use full path.)
      Add '-Djava.endorsed.dirs=$JBOSS_HOME/lib/endorsed' to your command line.
    3. Extremely slow startup and running of Embedded AS when using JDK logging.
      The JDK logging implementation is extremely slow, so jboss-ejb3-embeddable-standalone overrides this to use JBoss LogManager. This conflicts when you're using logging as well. The solution is to add jboss-logmanager to your class path (/project dependencies) and set '-Djava.util.logging.manager=org.jboss.logmanager.LogManager'. This also requires a proper logging configuration file.


    The source for all code used in this article can be found on GitHub,


    Please direct any questions to the EJB 3 space.