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
7
votes
1 answer

Java's ServiceLoader and test resources

I have a web application that defines a Hibernate Integrator as part of the Java ServiceLoader specification like so: src/main/resources/META-INF/services/org.hibernate.integrator.spi.Integrator # Define integrators that should be instantiated by…
EMMERICH
  • 3,424
  • 2
  • 18
  • 14
6
votes
1 answer

Why does the Eclipse JUnit4 Runner not pick up META-INF/services files

I am using Maven with Eclipse (using M2E) to build a project that relies on java.util.ServiceLoader to dynamically load some factory classes. It works fine when I run it in Maven, but when I run a test using the inbuilt Eclipse JUnit4 Runner, it…
Peter
  • 972
  • 7
  • 13
6
votes
0 answers

Java Proguard obfuscation on multiple projects at once (or save interface include definitions)?

I'm obfuscating/optimizing an app and a set of plugin/libraries (using ServiceLoader) via maven. The plugins are only created/maintained in the same code base as the app, it's not an interface intended for 3rd party development against, so…
bias
  • 1,467
  • 3
  • 19
  • 39
6
votes
1 answer

Java 9 ServiceLoader runtime module loading and replacement

I just read about Java 9 module system and I'd like to ask about ServiceLoader. Is there any way how to add service implementation when the application is already started? How about removing some service implementation? Use case: I will have some…
Zveratko
  • 2,663
  • 6
  • 35
  • 64
6
votes
1 answer

java.util.ServiceLoader not loading my provider class

I am trying to put together a basic SPI-based registry of Handlers, which I lookup from a HandlerRegistry. When I use the ServiceLoader.load(Handler.class) to initialize the providers, and then iterate the list to lazily load them, I am not seeing…
bachman
  • 141
  • 1
  • 1
  • 6
5
votes
1 answer

how to create fat jar which does not overwrite entries under META-INF/services

I have the following gradle build config: plugins { id 'com.github.johnrengelman.shadow' version '1.2.3' } group 'abc' version '1.0-SNAPSHOT' apply plugin: 'java' apply plugin: 'application' mainClassName = "abc.Driver" repositories { …
Ehsan
  • 298
  • 1
  • 3
  • 17
5
votes
2 answers

ClassNotFoundException when using ServiceLoader in Glassfish4 Java EE app

In a Java EE application, I'm trying to load serviced using Java's ServiceLoader. The .jar file I'm trying to load works in a test Java SE application, so I assume it's correct. However, the below code fails at…
Michael Bar-Sinai
  • 2,729
  • 20
  • 27
5
votes
1 answer

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…
pditommaso
  • 3,186
  • 6
  • 28
  • 43
5
votes
1 answer

Keep 'META-INF/services'-files in apk

I have a custom charset which is already working on JavaSE. The class of my CharsetProvider is specified in a file java.nio.charset.spi.CharsetProvider which is located in META-INF/services and everything get's loaded normally and works as…
AlexS
  • 5,295
  • 3
  • 38
  • 54
4
votes
0 answers

org.hibernate.boot.model.TypeContributor: Provider not found

I am trying to registrer list-array type provided by hibernate-types library using this approach in spring boot app. Unfortunatelly, when I start the app from console it throws the following exception: WARN o.h.b.r.c.i.AggregatedServiceLoader -…
Nikita Medvedev
  • 153
  • 1
  • 6
4
votes
1 answer

Use java serviceloader build with jdk8 use in >= java9

I have two jars. One provides a service interfaces and a service loading class and one provides the implementation of that service. This works perfectly when running this in jdk8, but I get an service type not accessible to unnamed module @3754a4bf…
Peter
  • 4,752
  • 2
  • 20
  • 32
4
votes
1 answer

Java 9: ServiceLoader doesn't load Test implementation from Test sources (Module)

I'm using Java9 Module system (running on openjdk11) I have migrated from Java8 and the code contained classes that made use of the ServiceLoader mechanism. a unit test for this class which tries to load two test service implementations the…
Gerald Mücke
  • 10,724
  • 2
  • 50
  • 67
4
votes
4 answers

What is ServiceLoader and how is it used?

I came across the documentation of ServiceLoader and am unclear as to what use cases it suits. When would one use ServiceLoader?
Patrik Mihalčin
  • 3,341
  • 7
  • 33
  • 68
4
votes
1 answer

Java Security Manager: Restrictions on code from external jar loaded via ServiceLoader

What am I trying to achieve? I am working on a java application that can be extended by additional jars that get integrated via ServiceLoader. These loaded extensions should run with some restrictions by the SecurityManager, of course simply to…
DataWorm
  • 73
  • 5
4
votes
0 answers

Using SystemLoader / SpringFactoryLoader to load external Jar in Spring-Project

first: I'm really new to spring-boot and maven. So I still don't get how everything plugs together. What I'm trying to achieve is some kind of plugin-feature for my application. From my research it seems the best way to do this is using…
mietzekotze
  • 195
  • 13
1
2
3
10 11