ApplicationComposer Maven Plugin

Even if it comes from test side of OpenEJB, ApplicationComposer is now a solution to develop microservices. Because of this evolution it now gets a maven plugin to be able to go further in the development pipeline.

Application Composer is a nice way to create a simple JavaEE application with OpenEJB
without worrying about the packaging – which doesn’t mean it is not powerful since you can
do JAX-RS, JAX-WS etc…

As a reminder a sample can look like:

@Classes(context = "/")
@EnableServices(jaxrs = true)
public class MyApp {

This is the most trivial example which will just deploy the jar containing MyApp class
enabling JAX-RS services on context root if they exist.

So, if we suppose our jar containers a User class (with a single name field)
and a resource returning a list of users:

public class UserResource {
    public List<User> list() {
        User user = new User();
        return asList(user);

Then running our main with the right dependencies (javaee-api + openejb-cxf-rs) will deploy the endpoint under http://localhost:4204/user.

Ok, but how do we run it?

The custom main

You can write a custom main using ApplicationComposers helper and just run your class like so:

public static void main(String[] args) {, args);

ApplicationComposers main

You can reuse the existing main:

java -cp lib/*.jar org.apache.openejb.testing.ApplicationComposers ...


There is also an applicationcomposer-maven-plugin which allows you to:

– run an application
– zip a distribution

Here is a sample configuration for our application:



mvn applicationcomposer:run

The server will start and deploy your endpoint.


mvn applicationcomposer:zip

The plugin will create a zip with this structure:

    ├── bin
    │   ├── applicationcomposer
    │   └── environment
    ├── classes
    │   └── org
    └── lib
        └── *.jar

Lib folder contains the container libraries, bin the script to run the server and classes your binaries (the jar doesn’t need to be built).

Note : by adding a conf/ and a log/ folder you’ll get a standard openejb structure (not created by default).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s