serviceloader

How to register a SPI implementation when running exec:java

亡梦爱人 提交于 2019-12-11 00:51:20
问题 I'm trying to make VertX Mertrics work when running via the exec:java Maven plugin. All works as expected when I package the application into a fatjar and run it with java -jar fat.jar -conf config.json -Dvertx.metrics.options.enabled=true When I run it with mvn clean package exec:java -DskipTests I see: 2016-03-22 18:39:58.833 WARN i.v.c.i.VertxImpl:348 - Metrics has been set to enabled but no VertxMetricsFactory found on classpath I tried several approaches: adding io.vertx:vertx-dropwizard

Java 11 Unable to derive module descriptor

柔情痞子 提交于 2019-12-08 21:15:43
问题 I am getting this error message when I try to compile my new modularized Java 11 application: Error occurred during initialization of boot layer java.lang.module.FindException: Unable to derive module descriptor for C:\Users\inter\.m2\repository\xalan\xalan\2.7.2\xalan-2.7.2.jar Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.apache.bsf.BSFManager not in module This appears to be an issue from a dependency of a dependency. I can't even find which module is

JUnit5 Platform Launcher API - Cannot create Launcher without at least one TestEngine

家住魔仙堡 提交于 2019-12-08 05:40:42
问题 I am attempting to upgrade the testing abilities of our automated testing suite to accept JUnit5 tests and when following The JUnit Platform Launcher API instructions I get the error "Cannot create Launcher without at least one TestEngine; consider adding an engine implementation JAR to the classpath" . The cause is that the following is unable to find any instances of TestEngine : Iterable<TestEngine> testEngines = ServiceLoader.load(TestEngine.class,ClassLoaderUtils.getDefaultClassLoader())

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

喜欢而已 提交于 2019-12-07 21:57:00
问题 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 { mavenCentral() } dependencies { compile (group: 'org.apache.hadoop', name: 'hadoop-client', version: '2.6.0') } sourceSets { main { java { srcDir './src' } } } jar { manifest { attributes( 'Class-Path': configurations.compile.collect { it.getName() }.join(' '),

How to make the java ServiceLoader work in a NetBeans 6.9 module application

♀尐吖头ヾ 提交于 2019-12-07 13:27:18
问题 I have troubles using the java ServiceLoader in a NetBeans module application. Here is what I'm trying to do (and it works in a normal java application in Eclipse): I have an interface.jar, which declares the interface. And I have implementations.jar, which has several implementations of this interface, all specified in the spi/META-INF/services/my.package.name.MyInteface file (this file is in the implemenations.jar). I also have a class ImplementationHandler (in yet another handler.jar),

ServiceLoader.next causing a NoClassDefFoundError

一笑奈何 提交于 2019-12-07 00:05:18
问题 I'm asking because I'm totally not sure I've done the right thing. I'm using Eclipse for a web project. Let's call it WebProject (duh) in the package com.web.project . I want WebProject to load JAR plugins at runtime, so I thought I could take advantage of java.util.ServiceLoader . So I created an interface com.web.project.WebProjectPlugin in the WebProject project with all the methods the plugins must implement. Then I created the project PluginProject, adding WebProbject/build/classes in

In Java, how can I mock a service loaded using ServiceLoader?

这一生的挚爱 提交于 2019-12-06 18:36:26
问题 I have a legacy Java application that has code something like this ServiceLoader.load(SomeInterface.class) and I want to provide a mock implementation of SomeInterface for this code to use. I use the mockito mocking framework. Unfortunately I am unable to change the legacy code, and I do not wish to add anything statically (eg. adding things to META-INF). Is there an easy way to do this from within the test, ie. at runtime of the test? 回答1: You can use PowerMockito along with Mockito to mock

Java SPI - ServiceLoader - adding multiple JAR's to APP classpath

末鹿安然 提交于 2019-12-06 13:09:24
问题 I have a problem implementing this logic in my project. Im using ServiceLoader and I don't know or if it's even possible, but I want to dynamically add JARs to some known directory for app, so the app can load them when it starts. The only thing I achieved was that I know how to create extensible ONE JAR (with META-INF/services), so I can add more and more providers and classes (implementations) to this JAR. The JAR is included to classpath like ordinary library, so app knows about it. What I

Java ServiceLoader explanation

这一生的挚爱 提交于 2019-12-06 06:45:15
问题 I'm trying to understand the Java ServiceLoader concepts, working mechanism and concrete use cases, but find the official documentation too abstract and confusing. First of all, documentation outlines services and service providers . Service is a set of interfaces and abstract classes packaged in a jar archive (API library). Service provider is a set of classes that implements or extends the API, packaged in a distinct jar file (Provider library). So far so good, but then the documentation

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

Deadly 提交于 2019-12-06 06:29:25
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 { mavenCentral() } dependencies { compile (group: 'org.apache.hadoop', name: 'hadoop-client', version: '2.6.0') } sourceSets { main { java { srcDir './src' } } } jar { manifest { attributes( 'Class-Path': configurations.compile.collect { it.getName() }.join(' '), 'Main-Class': mainClassName ) } } task fatJar(type: Jar) { manifest { attributes 'Implementation-Title'