OpenEJB ApplicationComposer and semi auto configuration

OpenEJB ApplicationComposer design is to let you build in memory JavaEE model of your application and then use it to really deploy the described application.

It is great when writing a microservice which aggregates several libraries (avoids to activate everything when you need just a subpart) but when you just write a single module it can seem a lot of work.

Since few days you can use @Default (openejb one) to ask to auto scan the module containing the main(String[]) for managed beans (CDI, EJB…) and descriptors (persistence.xml, …).

Here is a basic sample to write a simple jaxrs service:

@Classes(cdi = true)
public class MyApp {
    public static void main(String[] args) {, args);

Then if you have EJB, JAX-RS services, CDI beans then it will be activated automatically!

No need to define any @Module or list all CDI beans in @Classes(value).

For microservices or tests (since it works for tests as well) it allows quick activation of the “current” module without needing to be too explicit (ie listing all beans). With @Jars it allows to quickly setup its “EE-classpath” without much effort but keeping a full control on it.

This can be an interesting solution to run daemons or small internal webservices without needing a complicated packaging or loosing time and/or memory during boot.


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 )

Facebook photo

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

Connecting to %s