I have issues using the
ServiceLoader with the CLI build.
When I build my firmware with the launcher, the firmware works as expected.
When I build my firmware with the CLI tool, the firmware fails to retrieve the requested service (it is null).
Here is my code:
MyService myService = ServiceLoaderFactory.getServiceLoader().getService(MyService.class);
// myService is null
I have declared my service as follow:
What am I missing?
To work, the
ServiceLoader needs the class names of both the service interface and the service implementation.
To do so, you have two options:
- you may explicitely declare the types in a
*.types.list file (doc)
- you may embed all class names by setting the option
Now, regarding the different behavior you observe between a launcher and a CLI build.
Check the value of the option
soar.generate.classnames in your launcher (it is named
Embed all type names) and in the
build/*.properties files (doc).
I think your launcher has
Embed all type names checked whereas in one of your application properties files, you’ve disabled the
Hope that helps.
Hi, thanks for the quick reply.
Yes, that was exactly it.
For now we decided to embed all class names, we will turn it off if we need to gain some space.