vert-x3/vertx-config

IllegalArgumentException when running fat jar with additional store dependency

Closed this issue · 3 comments

jjank commented

Hi everybody,

I've encountered some minor issue when working with additional ConfigStores. I've created a little example app using the Kubernetes ConfigMap Store but the issue applies for all additional config stores.

According to the documentation one has to include both the vertx-config and the vertx-config-kubernetes-configmap artifacts as dependencies.

When you run the my example app on the broken branch via the maven exec-plugin or via a main-method, everything works fine. However if you run the fat jar I get an exception:

mvn clean package && java -jar target/config-demo-1.0.0-SNAPSHOT-fat.jar
java.lang.IllegalArgumentException: unknown configuration store implementation: configmap (known implementations are: [event-bus, file, json, http, env, sys, directory])
	at io.vertx.config.impl.ConfigRetrieverImpl.<init>(ConfigRetrieverImpl.java:110)
	at io.vertx.config.ConfigRetriever.create(ConfigRetriever.java:52)
	at com.github.wengertj.configdemo.MainVerticle.start(MainVerticle.java:21)
	at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$8(DeploymentManager.java:494)
	at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:320)
	at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:834)

The solution for me was to remove the vertx-config dependency (see the fixed branch). Now the fat jar runs just fine.
So my question is: Is this a bug or just something that the documentation should be more explicit about? Unfortunately I am not very familiar with ServiceLoaders and how that connects to the fat jar packaging. But I'd be glad to help out with a PR if you can point me into the right direction 👍

Thanks for the great work!

BTW: I encountered the exact same behavior on JDK 1.8 and JDK 11 (MacOs 10.14.2, Maven 3.5.4). Also changing the compilation target to 11 and upgrading the maven-shade-plugin did not change anything.

It's because of the SPI combination. Either you rewrite the SPI descriptor or just use the vertx-maven-plugin that would take care of this.

jjank commented

Ahh, very cool I just tried it and it works perfectly fine, thanks a lot!

I generated the project via start.vertx.io which did not use this plugin...yet? There is an open issue about this: vert-x3/vertx-starter#39. Maybe I can help out with a PR there.
There is also one pending PR in the vertx-maven-starter repo: vert-x3/vertx-maven-starter#3.

Thanks anyway I'm gonna close this one now :)

toien commented

for who use gradle shadow plugin, try this:

shadowJar{
    mergeServiceFiles()
}