Arquillian and TomEE embedded: multiple webapps, different CDI extensions


TomEE embedded made several progresses recently and it is nice to use with Arquillian. Since it is fully integrated with Arquillian you can deploy 2, 3 or much more webapps in the TomEE embedded instance…but then you have an issue: CDI. CDI extension mecanism is based on Java ServiceLoader mecanism. It means it uses META-INF/services/* to load its extensions. The issue: TomEE embedded is embedded. Of course it shares its container classloader with all applications but in this case you’ll get in 90% of cases your extension as well (cause of Maven, gradle, …). So it means if you deploy your application with the desired CDI extension and another (a test one) where you don’t want them you’ll get trouble since the extension will be loaded.

How to avoid it?

Continue reading

TomEE and log4j2


Since few weeks TomEE has some support for log4j2 without using log4j2-log4j compatibility module.

To set it up just add the log4j2 jars you want to tomee (lib/) and add your config – log4j2.xml – in the classloader (lib/ works too).

Side note: you can do it using a conf/jars.txt file and using log4j2 maven coordinates, really more easy ;).

Then in conf/system.properties (or in CATALINA_OPTS) set the system property openejb.log.factory to log4j2:

openejb.log.factory=log4j2

Then you’ll get the container logs redirected to log4j2.

CDI and ApplicationComposer: finally easy to test deltaspike with AppComposer


OpenEJB/TomEE ApplicationComposer design is to describe a test application with an in memory model close to the xml EE one (Beans for beans.xml, EjbJar for ejb-jar.xml…).

But when it comes to CDI and since it was mainly designed for small apps it is hard to say “I have a CDI dependency/library”.

The more obvious use case is DeltaSpike!

To make it easier we added @Jars recently.

Continue reading