Questions tagged [serviceloader]

ServiceLoader is a Java SDK way to load different providers for a class from the classpath. It uses special configuration files in META-INF/services.

The full documentation is provided by Oracle at http://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html

163 questions
1
vote
1 answer

is Java ServiceLoader using the System Class Loader, or the Platform/Extension Class Loader?

Java JDK ServiceLoader as some complex information, and I have a hard time getting this one thing straight: Which class loader it uses. This question concerns the range of JDKs from JDK8 to JDK17. There are three static instantiation functions in…
foo
  • 1,968
  • 1
  • 23
  • 35
1
vote
1 answer

java.util.ServiceLoader not able to load provider

I've been trying to resolve my problems for several days without success and need help. We've been upgrading our java version from 8 to 17 in our application (more than 20) and with only 2 of them we have met this error: Caused by:…
Giacomo Giovannini
  • 177
  • 2
  • 2
  • 14
1
vote
1 answer

Testing ServiceLoader in Eclipse Plugins

I have four Eclipse plugin projects (create a new Java Project, right-click, configure, Convert to Plugin Project) in my workspace. The first (my.runtime) contains an interface (MyFactoryInterface) and a class (MyClient) that defines a method…
hd42
  • 1,741
  • 15
  • 30
1
vote
1 answer

how can i use jar of another project in my project at run-time in spring-boot without mentioning it to the pom.xml of my project

I want to create a project in spring boot in module pattern, there are four modules in my project moduleA, moduleB, moduleC and moduleD. moduleB contains the a interface. moduleC and moduleD contains the implementation of interface that is present…
1
vote
0 answers

Use Koin instead of ServiceLoader for plugin discovery

I've so far used Java's ServiceLoader to discover implementations of interfaces my app provides at runtime in the classpath, i.e. a classic plugin approach. I'm now starting to use Koin in the app (for Dependency Injection) and wondering whether I…
sschuberth
  • 28,386
  • 6
  • 101
  • 146
1
vote
1 answer

Javalin with JPMS and ServiceLoader results in NoClassDefFoundError: kotlin/NoWhenBranchMatchedException

Running Javalin with JPMS and ServiceLoader leads to a NoClassDefFoundError: kotlin/NoWhenBranchMatchedException. The same code following two other approaches works fine, though (see at the end of this post for details): No JPMS and ServiceLoader:…
baumgarb
  • 1,955
  • 3
  • 19
  • 30
1
vote
0 answers

Service Loader Can't Find Provider

I am having trouble getting the service loader to find my providers. My set up is as follows: I have 4 modules: EntryPoint Library Version1 Version2 In Library, I have an interface defined: interface Parent{ fun doSomething() fun…
cershif
  • 154
  • 1
  • 13
1
vote
0 answers

How is activation happening in the Java SPI modules?

I am working on a task that migrates the OSGI modules to Java SPI modules. Let's say I have three OSGI(A, B, C) modules. So each module has a class for activation and activation happening when starting the servers(at the beginning). Service…
Shamly
  • 23
  • 4
1
vote
1 answer

Java9 modules : How to execute Provider based on some priority of execution?

I am using java 9 modules to implement provider , i have multiple providers for service interface. I want to provide some priority for providers for their execution insted of using findFirst(); Optional
Akhilesh Pandey
  • 855
  • 5
  • 10
1
vote
1 answer

ServiceLoader can't find my implementation

I'm trying to use ServiceLoader with modules system, the same way as shown in the Deploying service providers as modules header in the documentation here - click I have the following project: module tester.client package tester.client; import…
Wiktor
  • 89
  • 6
1
vote
0 answers

Service loading: how to write plugins on Kotlin native?

In Java you are able to write plugins for your application with ServiceLoader. In this case you can define: interface A and class B implements A and simply in your code do the following: Create an external plugin with a configuration, where you…
1
vote
0 answers

ServiceLoader works different, when starting from JAR

We use external libraries for generating pdf-files with some specific content. As long as we run it as java program in the IDE, everything works as expected. But, when we build a jar with the maven-assembly-plugin, and then try to run this as a JAR…
Val Rafisa
  • 36
  • 3
1
vote
1 answer

ServiceLoader with UrlClassLoader not finding service

I am trying to load plugins from a certain jar file using the java ServiceLoader with an UrlClassLoader, but I just cannot seem to get it to find my plugin classes. Building both modules works, but whenever I run the code below, I get a…
Jakob Tinhofer
  • 313
  • 3
  • 16
1
vote
0 answers

Loading ResourceBundle from named modules

Let's suppose that module A (provider) contains messages.properties and we want to load it as ResourceBundle from module B. Javadoc literally suggests the following approach. Provider module: module provider { exports provider; exports…
1
vote
2 answers

How can I find all JDBC drivers available?

I have a library method that can be used to connect to a database and then build a document using data from the database. When they run this app with no parameters, I want to list out all available sql vendor connections. Based on this question I'm…
David Thielen
  • 28,723
  • 34
  • 119
  • 193