Gangmax Blog

Vert.x Error When Running within Fat Jar

I have a web application project written with “vert.x”. When I run it in IntelliJ IDEA it works fine, however when I run it as a fat jar it reports the following error when starting and then stops:

1
2
3
4
5
6
7
> java -jar revas-1.0.0-all.jar
date=2025-02-27T10:31:55,361,level=INFO,thread=main,logger=revas.starter.MainApp: Starting 'maps-china-request-validator' service...
date=2025-02-27T10:31:55,607,level=INFO,thread=main,logger=revas.starter.MainApp: options.getStores().size(): 0
Exception in thread "main" java.lang.IllegalArgumentException: unknown configuration store implementation: json (known implementations are: [vault])
at io.vertx.config.impl.ConfigRetrieverImpl.<init>(ConfigRetrieverImpl.java:111)
at io.vertx.config.ConfigRetriever.create(ConfigRetriever.java:53)
at revas.starter.MainApp.main(MainApp.java:60)

I googled “unknown configuration store implementation: json (known implementations are: [vault]” and find the following posts:

  1. Explanation

  2. Solution

The root cause is that, when packaging a fat jar, by default it won’t merge the service files under the “META-INF/services/“ path in each jar file. So when there’re multiple jar files with such service files, some content is missing. To make the fat jar creation process do the merge, add the following content into the “build.gradle” file.

1
2
3
shadowJar{
mergeServiceFiles()
}

After that, the created fat jar works fine.

Comments