Unable to load sun.util.resources.cldr.provider.CLDRLocaleDataMetaInfo
Asked Answered
L

5

9

I've started getting a rather cryptic error in one of my tests. Surefire report is as follows:

-------------------------------------------------------------------------------
Test set: de.systel.streckenmatching.GeoCoordinateTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.129 sec <<< FAILURE!
de.systel.streckenmatching.GeoCoordinateTest  Time elapsed: 0.128 sec  <<< ERROR!
java.util.ServiceConfigurationError: sun.util.locale.provider.LocaleDataMetaInfo: Unable to load sun.util.resources.cldr.provider.CLDRLocaleDataMetaInfo
    at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:584)
    at java.base/java.util.ServiceLoader.loadProvider(ServiceLoader.java:856)
    at java.base/java.util.ServiceLoader$ModuleServicesLookupIterator.hasNext(ServiceLoader.java:1078)
    at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1301)
    at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1386)
    at java.base/sun.util.cldr.CLDRLocaleProviderAdapter$1.run(CLDRLocaleProviderAdapter.java:89)
    at java.base/sun.util.cldr.CLDRLocaleProviderAdapter$1.run(CLDRLocaleProviderAdapter.java:86)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
    at java.base/sun.util.cldr.CLDRLocaleProviderAdapter.<init>(CLDRLocaleProviderAdapter.java:86)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:124)
    at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:346)
    at java.base/java.lang.Class.newInstance(Class.java:604)
    at java.base/sun.util.locale.provider.LocaleProviderAdapter.forType(LocaleProviderAdapter.java:176)
    at java.base/sun.util.locale.provider.LocaleProviderAdapter.findAdapter(LocaleProviderAdapter.java:279)
    at java.base/sun.util.locale.provider.LocaleProviderAdapter.getAdapter(LocaleProviderAdapter.java:250)
    at java.base/java.text.DecimalFormatSymbols.getInstance(DecimalFormatSymbols.java:180)
    at java.base/java.util.Formatter.getZero(Formatter.java:2437)
    at java.base/java.util.Formatter.<init>(Formatter.java:1956)
    at java.base/java.util.Formatter.<init>(Formatter.java:1978)
    at java.base/java.lang.String.format(String.java:3302)
    at org.junit.runner.Description.formatDisplayName(Description.java:114)
    at org.junit.runner.Description.createTestDescription(Description.java:86)
    at org.junit.runners.BlockJUnit4ClassRunner.describeChild(BlockJUnit4ClassRunner.java:96)
    at org.junit.runners.BlockJUnit4ClassRunner.describeChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:352)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:359)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.LinkageError: loader 'platform' attempted duplicate class definition for sun.util.resources.cldr.provider.CLDRLocaleDataMetaInfo. (sun.util.resources.cldr.provider.CLDRLocaleDataMetaInfo is in module jdk.localedata of loader 'platform')
    at java.base/java.lang.ClassLoader.defineClass2(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1109)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:183)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:780)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassInModuleOrNull(BuiltinClassLoader.java:701)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClass(BuiltinClassLoader.java:582)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:634)
    at java.base/java.lang.Class.forName(Class.java:505)
    at java.base/java.util.ServiceLoader.loadProvider(ServiceLoader.java:854)
    ... 40 more
Caused by: java.lang.LinkageError: loader 'platform' attempted duplicate class definition for sun.util.resources.cldr.provider.CLDRLocaleDataMetaInfo. (sun.util.resources.cldr.provider.CLDRLocaleDataMetaInfo is in module jdk.localedata of loader 'platform')
    at java.base/java.lang.ClassLoader.defineClass2(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1109)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:183)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:780)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassInModuleOrNull(BuiltinClassLoader.java:701)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClass(BuiltinClassLoader.java:582)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:634)
    at java.base/java.lang.Class.forName(Class.java:505)
    at java.base/java.util.ServiceLoader.loadProvider(ServiceLoader.java:854)
    ... 40 more

The test itself is absolutely nothing special, just validating equals for some POJO classes:

public class GeoCoordinateTest {

    @Test
    public void test() {
        
        
        GeoCoordinate coord1 = new GeoCoordinate();
        coord1.setLatitude(5.0);
        coord1.setLongitude(10.0);

        GeoCoordinate coord2 = new GeoCoordinate();
        coord2.setLatitude(5.0);
        coord2.setLongitude(10.0);
        
        GeoCoordinate coord3 = new GeoCoordinate();
        coord3.setLatitude(5.1);
        coord3.setLongitude(10.0);
        
        
        assertEquals(coord1, coord2);
        assertNotEquals(coord1, coord3);
    }

}

It happens under OpenJDK 14:

...>java -version
openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+7)
OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)

I am puzzled. What is happening and how do I fix this?

Lenticularis answered 26/6, 2020 at 8:18 Comment(2)
The stack trace format module/class... (like java.base/java.util.ServiceLoader) suggests maven is being run on JDK 9+. Please check your JAVA_HOME variable. Or test mvn -v to see which JDK it's using.Anglocatholic
@Anglocatholic Was in fact a wrong JDK (OpenJDK 14).Lenticularis
O
4

I had this happen when I was upgrading from Java 8 to Java 11 while running the test with JetBrains' IDE Intellij IDEA.

What was happening in my case was that the Project SDK was different from the one being used by the 'platform'.

In my case, the platform was Gradle's JVM. If anyone comes across this, know that you can set up the Build Tool to match the Project SDK by going to Preferences > Build, Execution, Deployment > Build Tools. Here you have options for Gradle or the question's Maven, among others.

Oldtime answered 1/3, 2021 at 19:30 Comment(0)
A
1

The same happened to me when I was upgrading from JDK11 to JDF15. This problem appears at JDK14+, but is fine at JDK13.

Alvardo answered 10/11, 2020 at 13:14 Comment(0)
J
1

This problem occurred to me in an automated test project with JDK 15, TestNG, mongo-java-driver, Selenium, and other dependencies.

I had to upgrade to JDK 15 due to a bug in the mongo-driver with JDK 13. After this update, the error "Unable to load sun.util.resources.cldr.provider.CLDRLocaleDataMetaInfo" started to occur.

I solved it with the maven settings that I put below.

<properties>
    <jacoco.version>0.8.6</jacoco.version>
</properties>

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <systemPropertyVariables>
                <jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
            </systemPropertyVariables>
        </configuration>
    </plugin>
    <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco.version}</version>
        <executions>
            <execution>
                <id>default-prepare-agent</id>
                <goals>
                    <goal>prepare-agent</goal>
                </goals>
            </execution>
            <execution>
                <id>default-report</id>
                <phase>prepare-package</phase>
                <goals>
                    <goal>report</goal>
                </goals>
            </execution>
        </executions>

    </plugin>
</plugins>
Jacquejacquelin answered 25/2, 2021 at 15:52 Comment(3)
Excellent. I would be cool if you could add some narrative describing how the solution solves the problem.Karlie
This problem occurred to me in an automated test project with JDK 15, TestNG, mongo-java-driver, Selenium, and other dependencies. I had to upgrade to JDK 15 due to a bug in the mongo-driver with JDK 13. After this update, the error "Unable to load sun.util.resources.cldr.provider.CLDRLocaleDataMetaInfo" started to occur. I solved it with the maven settings that I put above.Jacquejacquelin
Cool. Sorry I meant update your answer textKarlie
E
0

I had the exactly the same issue with Java 8, Eclipse 2021-03 (refreshly installed). Apparently Eclipse comes with its own JRE, and Gradle will use it as default. To fix the issue, you need to go to Preferences > Gradle and manually change Java Home to match your default/system/project Java Home.

Emera answered 18/3, 2021 at 18:11 Comment(0)
R
0
java.util.ServiceConfigurationError: sun.util.locale.provider.LocaleDataMetaInfo: Unable to load sun.util.resources.cldr.provider.CLDRLocaleDataMetaInfo at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:582)

solution that worked for me : the build.gradle in my project has java version as 11 and in machine it was 17 so i just changed the build.gradle version 11 to 17, that worked for me.

Riobard answered 23/9, 2024 at 8:1 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.