Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.33k stars 1.97k forks source link

[QUERY] NoSuchMethodError for Azure Management Java SDK #30327

Closed ihsanhaikalz closed 2 years ago

ihsanhaikalz commented 2 years ago

I am really new with Azure Java SDK and I would like to run Azure Management Java SDK following https://docs.microsoft.com/en-us/java/api/overview/azure/resourcemanager-apimanagement-readme?view=azure-java-preview and https://github.com/Azure/azure-sdk-for-java/blob/azure-resourcemanager-apimanagement_1.0.0-beta.3/sdk/resourcemanager/docs/AUTH.md with the code as follows:

    AzureProfile profile = new AzureProfile(tenantId, subscriptionId, AzureEnvironment.AZURE);
    final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
            .clientId(clientId)
            .clientSecret(clientSecret)
            .tenantId(tenantId)
            .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())

            .build();
    ApiManagementManager manager = ApiManagementManager.authenticate(clientSecretCredential, profile);

However, when I run the code it would return this error on the ApiManagementManager:

    java.lang.NoSuchMethodError: 'void com.azure.core.util.serializer.JacksonAdapter.<init>(java.util.function.BiConsumer)'
        at com.azure.core.management.implementation.serializer.AzureJacksonAdapter.<init>(AzureJacksonAdapter.java:17)
        at com.azure.core.management.serializer.SerializerFactory.createDefaultManagementSerializerAdapter(SerializerFactory.java:26)
        at com.azure.resourcemanager.apimanagement.implementation.ApiManagementClientBuilder.buildClient(ApiManagementClientBuilder.java:142)
        at com.azure.resourcemanager.apimanagement.ApiManagementManager.<init>(ApiManagementManager.java:350)
        at com.azure.resourcemanager.apimanagement.ApiManagementManager.<init>(ApiManagementManager.java:186)
        at com.azure.resourcemanager.apimanagement.ApiManagementManager$Configurable.authenticate(ApiManagementManager.java:525)
        at com.azure.resourcemanager.apimanagement.ApiManagementManager.authenticate(ApiManagementManager.java:363)

Any idea why?

joshfree commented 2 years ago

Hi @ihsanhaikalz thank you for reaching out to us via this GitHub issue. Someone from the control plane SDK team will follow up with you shortly.

You can also refer to https://docs.microsoft.com/en-us/azure/developer/java/sdk/troubleshooting-dependency-version-conflict and https://devblogs.microsoft.com/azure-sdk/dependency-management-for-java/ for guidance on how to resolve dependency conflicts in the local client side application.

weidongxu-microsoft commented 2 years ago

@ihsanhaikalz

Please see https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/resourcemanager#dependency-management

Your project likely having conflict version of azure-core. Please make it the latest version.

ghost commented 2 years ago

Hi @ihsanhaikalz. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

ghost commented 2 years ago

Hi @ihsanhaikalz, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.