java.lang.NoClassDefFoundError: Could not initialize class com.azure.identity.implementation.RegionalAuthority

Navjot 46 Reputation points
2024-10-16T22:19:29.19+00:00

Describe the bug

We are in process of writing PT scripts (using JMeter) so that they can be executed using Azure Load test tool. As part of this project, we need to store our test login credentials in Azure key vault so that these PT scripts can read these credentials from vault during run time. To achieve this, we have written a piece of code in JSR223 preprocessor using Groovy language. But its throwing below error: 

Below is the code written in JSR223 preprocessor

import com.azure.identity.implementation.*

import com.azure.identity.DefaultAzureCredentialBuilder

import com.azure.security.keyvault.secrets.SecretClientBuilder

def SecretName = "mysecretname";

def keyVaultName = "myVaultName";

def keyVaultUri = "https://${keyVaultName}.vault.azure.net/";

def credential = new DefaultAzureCredentialBuilder().build() - Line of error

def client = new SecretClientBuilder().vaultUrl(keyVaultUri).credential(credential).buildclient()

def secretvalue = client.getSecret(SecretName).getValue()

vars.put("password",password)

Error Message:

2024-10-16 14:45:34,181 ERROR o.a.j.JMeter: Uncaught exception in thread Thread

java.lang.NoClassDefFoundError: Could not initialize class com.azure.identity.implementation.RegionalAuthority

at com.azure.identity.implementation.IdentityClientOptions.<init>(IdentityClientOptions.java:99) ~[azure-identity-1.13.3.jar:1.13.3]

at com.azure.identity.CredentialBuilderBase.<init>(CredentialBuilderBase.java:47) ~[azure-identity-1.13.3.jar:1.13.3]

at com.azure.identity.DefaultAzureCredentialBuilder.<init>(DefaultAzureCredentialBuilder.java:77) ~[azure-identity-1.13.3.jar:1.13.3]

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?]

at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]

at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]

at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?]

at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:72) ~[groovy-3.0.20.jar:3.0.20]

at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105) ~[groovy-3.0.20.jar:3.0.20]

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59) ~[groovy-3.0.20.jar:3.0.20]

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:263) ~[groovy-3.0.20.jar:3.0.20]

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:268) ~[groovy-3.0.20.jar:3.0.20]

at Script4.run(Script4.groovy:13) ~[?:?]

at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317) ~[groovy-jsr223-3.0.20.jar:3.0.20]

at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:71) ~[groovy-jsr223-3.0.20.jar:3.0.20]

at java.scripting/javax.script.CompiledScript.eval(CompiledScript.java:93) ~[java.scripting:?]

at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:230) ~[ApacheJMeter_core.jar:5.6.3]

at org.apache.jmeter.extractor.JSR223PostProcessor.process(JSR223PostProcessor.java:45) ~[ApacheJMeter_components.jar:5.6.3]

at org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:973) ~[ApacheJMeter_core.jar:5.6.3]

at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:585) ~[ApacheJMeter_core.jar:5.6.3]

at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:501) ~[ApacheJMeter_core.jar:5.6.3]

at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:268) ~[ApacheJMeter_core.jar:5.6.3]

at java.base/java.lang.Thread.run(Thread.java:842) [?:?]

Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.BootstrapMethodError: java.lang.SecurityException: class "com.azure.core.implementation.ReflectiveInvoker"'s signer information does not match signer information of other classes in the same package [in thread "Login-Logout 1-1"]

at com.azure.core.util.ExpandableStringEnum.fromString(ExpandableStringEnum.java:70) ~[azure-core-1.53.0.jar:1.53.0]

at com.azure.identity.implementation.RegionalAuthority.fromString(RegionalAuthority.java:287) ~[azure-identity-1.13.3.jar:1.13.3]

at com.azure.identity.implementation.RegionalAuthority.<clinit>(RegionalAuthority.java:19) ~[azure-identity-1.13.3.jar:1.13.3]

at com.azure.identity.implementation.IdentityClientOptions.<init>(IdentityClientOptions.java:99) ~[azure-identity-1.13.3.jar:1.13.3]

at com.azure.identity.CredentialBuilderBase.<init>(CredentialBuilderBase.java:47) ~[azure-identity-1.13.3.jar:1.13.3]

at com.azure.identity.DefaultAzureCredentialBuilder.<init>(DefaultAzureCredentialBuilder.java:77) ~[azure-identity-1.13.3.jar:1.13.3]

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?]

Environment:

JMeter : latest version

Java version : 17

OS : Windows

Jars included in JMeter Library: -

  • Azure-common 1.8.0
  • Azure-core 1.53.0
  • Azure-identity 1.13.3
  • Azure-security-keyvault-secrets 4.8.6
  • msal4j 1.13.3
Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,448 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Navjot 46 Reputation points
    2024-10-21T17:34:14.41+00:00

    i have fixed the issue by using ManagedIdentityCredentialBuilder() instead of DefaultAzureCredentialBuilder().

    0 comments No comments

  2. Raja Pothuraju 23,465 Reputation points Microsoft External Staff Moderator
    2024-10-25T19:53:30.7566667+00:00

    Hello @Navjot,

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.

    Issue: java.lang.NoClassDefFoundError: Could not initialize class com.azure.identity.implementation.RegionalAuthority

    Solution: Resolved by @Navjot,

    Fixed the issue by using ManagedIdentityCredentialBuilder() instead of DefaultAzureCredentialBuilder().

    If you have any other questions or are still running into more issues, please let me know. Thank you again for your time and patience throughout this issue.

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    Thanks,
    Raja Pothuraju.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.