quarkus: ConfigSourceProvider not working with uber-jar in 1.4.1.Final

Describe the bug The Quarkus Build (mvn package) fails when the project is using a ConfigSourceProvider. This only happens when quarkus.package.uber-jar is set to true.

Expected behavior The build should be successful, as in 1.3.2.Final or older

Actual behavior This build fails with the following error message:

 Failed to build quarkus application: java.nio.file.FileSystemException: path\to\project\config-service\target\config-service-1.0-SNAPSHOT.jar -> path\to\project\config-service\target\config-service-1.0-SNAPSHOT.jar.original: The process cannot access the file because it is being used by another process.

To Reproduce Steps to reproduce the behavior:

  1. Create a Quarkus-Project with version 1.4.1.Final
  2. Add another properties-File to src/main/resources (in this example called more.properties)
  3. Add the following CustomConfigSourceProvider to the project
import io.smallrye.config.PropertiesConfigSource;
import org.eclipse.microprofile.config.spi.ConfigSource;
import org.eclipse.microprofile.config.spi.ConfigSourceProvider;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class CustomConfigSourceProvider implements ConfigSourceProvider {

    @Override
    public Iterable<ConfigSource> getConfigSources(ClassLoader classLoader) {
        List<ConfigSource> configs = new ArrayList<>();
        try {
            configs.add(new PropertiesConfigSource(classLoader.getResource("more.properties")));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return configs;
    }
}
  1. Add a file called org.eclipse.microprofile.config.spi.ConfigSourceProvider into META-INF\services and put the fully qualified name of the CustomConfigSourceProvider in it
  2. Set quarkus.package.uber-jar=true
  3. mvn package

Configuration

quarkus.package.uber-jar=true

Environment (please complete the following information):

  • Output of uname -a or ver: Microsoft Windows [Version 10.0.17763.1098]
  • Output of java -version: openjdk version “11.0.3-ojdkbuild” 2019-04-16 LTS OpenJDK Runtime Environment 18.9 (build 11.0.3-ojdkbuild+7-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.3-ojdkbuild+7-LTS, mixed mode)
  • Quarkus version or git rev: 1.4.1.Final
  • Build tool (ie. output of mvnw --version or gradlew --version): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: path\to\maven\apache-maven-3.6.3\bin.. Java version: 11.0.3-ojdkbuild, vendor: Oracle Corporation, runtime: C:\Program Files\JavaSoft\OpenJDK\11.0.3.7 Default locale: de_DE, platform encoding: Cp1252 OS name: “windows 10”, version: “10.0”, arch: “amd64”, family: “windows”

Additional context I could recreate the same error with a ConfigSource by using Java 8. An update to Java 11 solved the problem with the ConfigSource, but for the ConfigSourceProvider it is still as described.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 24 (19 by maintainers)

Most upvoted comments

I believe this is out of scope of our resolution, due to the issues with the ServiceLoader, JDK 8 and Windows. The recommended approach would be to use a separate module or jar that provides the custom Provider or Source.

This should fix this issue: https://github.com/smallrye/smallrye-config/commit/0391e243e3b07c227a0c33326e0ed48598301aa0.

But, I haven’t really tested it against this reproducer, so I’ll have a look.