groovyjmeterazure-keyvaultnoclassdeffounderrorazure-identity

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


Being from a testing background, I am novice to developer's area of libraries/classes/methods so requesting your patience :)

Context: We are in process of writing load testing scripts (using JMeter). 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:

Runtime Environment - JMeter: latest version, Java version: 17, OS: Windows

Based on the findings over web, tried adding below Jars in JMeter Library but no luck.

Please let me know if any more information is needed. Will appreciate if anyone can guide on above issue.

Below is the Groovy code in JSR223 preprocessor and Error Details

 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:as seen in JMeter log viewer

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\]
.....
**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\]`
..

Solution

  • i have fixed the issue by using ManagedIdentityCredentialBuilder() instead of DefaultAzureCredentialBuilder(). Thanks all for your response and support :)