Running an embeddable container
Use this task to run an embeddable container. Applications running in the embeddable container start faster and require a smaller footprint than when running in the full application server. It is an ideal environment for quickly developing and testing applications that might eventually run in the application server.
Before you begin
Before running an embeddable container, you must have the
following items ready:
- A copy of the
<app_server_root>\runtimes\com.ibm.ws.ejb.embeddableContainer_9.0.jarRestriction: The Enterprise JavaBeans (EJB) thin client, com.ibm.ws.ejb.thinclient_9.0.jar, and the EJB embeddable Java™ archive (JAR) file, com.ibm.ws.ejb.embeddableContainer_9.0.jar, cannot coexist in the same class path.
- A copy of the <app_server_root>\runtimes\endorsed\endorsed_apis_9.0.jar file, if you are using the @Resource annotation with the lookup attribute
- One or more EJB modules in JAR files or class directories
- A main class that creates the embeddable container
- A Java SE Development Kit (JDK) or a Java Runtime Environment (JRE) Version 8.0 or later
About this task
The key to running the embeddable container is the class
path. The class path must include all the artifacts previously listed.
For example, if the main class is my.pkg.MyMainClass, and it uses
enterprise beans that are stored in the MyEJBModule.jar file,
the following line might run the main class that launches the embeddable
container. This example assumes that all JAR files and class directories
are in the current working directory.
- Windows:
C:\test> java -cp .;com.ibm.ws.ejb.embeddableContainer_9.0.jar my.pkg.MyMainClass
- UNIX:
[test]$ java -cp .:com.ibm.ws.ejb.embeddableContainer_9.0.jar:MyEJBModule.jar my.pkg.MyMainClass
If you want to specify embeddable
container properties in a text file other than embeddable.properties
in the current working directory, then you must specify the com.ibm.websphere.embeddable.configFileName
system property; for example:
- Windows:
C:\test> java -Dcom.ibm.websphere.embeddable.configFileName="C:\test\my-config.properties" -cp .;com.ibm.ws.ejb.embeddableContainer_9.0.jar;MyEJBModule.jar my.pkg.MyMainClass
- UNIX:
[test]$ java -Dcom.ibm.websphere.embeddable.configFileName="/home/myusername/test/my-config.properties" -cp .:com.ibm.ws.ejb.embeddableContainer_9.0.jar:MyEJBModule.jar my.pkg.MyMainClass
When you are developing an application that uses JPA in the embeddable EJB container, the class
path must include the JPA thin client, com.ibm.ws.jpa-2.1.thinclient_9.0.jar.
The JPA thin client is located in \runtimes where the root directory of the
installation image is located.
- Windows:
C:\test> java -cp .;com.ibm.ws.ejb.embeddableContainer_9.0.jar;%WAS_HOME%\runtimes \com.ibm.ws.jpa-2.1.thinclient_9.0.jar;MyEJBModule.jar my.pkg.MyMainClass
- UNIX:
[test]$ java -cp .:com.ibm.ws.ejb.embeddableContainer_9.0.jar:${WAS_HOME}/runtimes /com.ibm.ws.jpa-2.1.thinclient_9.0.jar:MyEJBModule.jar my.pkg.MyMainClass


- Windows:
C:\test> java -javaagent:%WAS_HOME%\runtimes\com.ibm.ws.jpa-2.1.thinclient_9.0.jar -cp .;com.ibm.ws.ejb.embeddableContainer_9.0.jar;MyEJBModule.jar my.pkg.MyMainClass
- UNIX:
[test]$ java -javaagent:${WAS_HOME}/runtimes/com.ibm.ws.jpa-2.1.thinclient_9.0.jar -cp .:com.ibm.ws.ejb.embeddableContainer_9.0.jar:MyEJBModule.jar my.pkg.MyMainClass
To enable tracing in the embeddable container, you can
specify the com.ibm.ejs.ras.lite.traceSpecification system property
to a trace specification value as you would specify for the server.
By default, the trace is printed to standard output, but you can redirect
the output by specifying the com.ibm.ejs.ras.lite.traceFileName system
property. The following example shows how you can use both system
properties:
- Windows:
C:\test> java -Dcom.ibm.ejs.ras.lite.traceSpecification=EJBContainer=all:MetaData=all -Dcom.ibm.ejs.ras.lite.traceFileName=trace.log -cp .;com.ibm.ws.ejb.embeddableContainer_9.0.jar;MyEJBModule.jar my.pkg.MyMainClass
- UNIX:
[test]$ java -Dcom.ibm.ejs.ras.lite.traceSpecification=EJBContainer=all:MetaData=all -Dcom.ibm.ejs.ras.lite.traceFileName=trace.log -cp .:com.ibm.ws.ejb.embeddableContainer_9.0.jar:MyEJBModule.jar my.pkg.MyMainClass
If your beans use the javax.annotation.Resource annotation with the lookup attribute, you must
also use the Java Endorsed Standards Override Mechanism to
override the javax.annotation.Resource API that is available in the JDK on your system. Copy the
app_server_root\runtimes\endorsed\endorsed_apis_9.0.jar file
into a target directory of your choice. Use the java.endorsed.dirs property on
the Java command to specify your directory that contains the
copied JAR file. The following example shows how you can specify the java.endorsed.dirs property:
- Windows:
C:\test> java -Djava.endorsed.dirs="myTargetDirectory" -cp .;com.ibm.ws.ejb.embeddableContainer_9.0.jar;MyEJBModule.jar my.pkg.MyMainClass
- UNIX:
[test]$ java -Djava.endorsed.dirs="myTargetDirectory" -cp .:com.ibm.ws.ejb.embeddableContainer_9.0.jar:MyEJBModule.jar my.pkg.MyMainClass