Primitive Axon App run as Fat JAR Doesn't Autoconfigure Axon Beans

At I’ve made up a simple Axon-app to show that JAR-artifact built with Gradle-plugin ``

doesn’t autoconfigure Axon beans when (when run as JAR). Though it runs fine under Intellij.

From project root in terminal:

run gradle clean build shadowJar; java -jar build/simpleaxon.jar;

Stacktrace is enclosed. I expect that Axon Autocongiguration provides beans like CommandBus, Snapshotter and other by default.

StackTrace (9.24 KB)

Hi Andrey,

I’ve seen you’ve gone the stretch and not only created a user group issue, but also a StackOverflow question and a GitHub issue.

To keep things simple for me, I will copy over my answer I gave on StackOverflow and on the GitHub issue:

So, this took my some investigation to get a hunch what is going wrong, but I know what the problem is.
Quick notice, it’s not an Axon specific thing, rather the plugin you are using.

I ran your sample project and indeed ended up with the same result; no Axon beans were being wired, ever. That led me to investigate the process of creating fat JAR’s step by step. First Maven, then Spring Boot with Maven, then Gradle with Spring Boot and finally with the Shadow plugin you are referring too.

This endeavour landed me on this issue, which states as much as “projects which require the use of META-INF files need to add this to the shadow plugin, and this should be documented”.

The portion referenced through this is the following:

import com.github.jengelman.gradle.plugins.shadow.transformers.PropertiesFileTransformer

// Left out all other specifics from your 'build.gradle' file
shadowJar {
// Required for Spring
append 'META-INF/spring.handlers'
append 'META-INF/spring.schemas'
append 'META-INF/spring.tooling'
transform(PropertiesFileTransformer) {
paths = ['META-INF/spring.factories' ]
mergeStrategy = "append"

getDestinationDirectory().set(new File(projectDir, "./build"))

After adding that piece of logic to your build.gradle file, I could run your sample project as expected.

Trusting this will help you out Andrey, and potentially others using the plugin too.


Steven van Beelen

Axon Framework Lead Developer