Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How use Java ServiveLocator with One-Jar

I'm packaging an application of mine in a single jar using the One-Jar tool:

http://one-jar.sourceforge.net/

It works nike, but I have a problem with a service implemented in a dependency module, which is implemented in a separate jar.

The module uses the standard Java ServiceLoader mechanism to provide its service i.e. the jar has a file META-INF/services/package.name.ServiceProviderClass which specifies the service concrete class to be instantiated.

BUT when this jar is embedded in the application "fat-jar", created by One-Jar, the the service it is NOT discovered by the service loader mechanism.

Any idea how to make it work?

Cheers, Paolo

like image 957
pditommaso Avatar asked Nov 02 '22 13:11

pditommaso


1 Answers

At the end I solved this problem by using Capsule packaging in place of One-jar

http://github.com/puniverse/capsule

Enjoy

like image 102
pditommaso Avatar answered Nov 15 '22 05:11

pditommaso