Azure-sdk-for-java: [BUG] class "com.azure.core.util.ClientOptions"'s signer information does not match signer information of other classes in the same package

Created on 8 Dec 2020  路  5Comments  路  Source: Azure/azure-sdk-for-java

Describe the bug
Getting the below error message while adding the azure-messaging-servicebus library.
A clear and concise description of what the bug is.

Exception or Stack Trace
class "com.azure.core.util.ClientOptions"'s signer information does not match signer information of other classes in the same package

To Reproduce
Steps to reproduce the behavior:
Attached the

Code Snippet
_Definition_

package com.utils.core.azure.servicebus;

import com.azure.core.amqp.implementation.TracerProvider;
import com.azure.core.util.tracing.Tracer;
import com.azure.messaging.servicebus.*;
import com.azure.messaging.servicebus.implementation.models.ServiceBusProcessorClientOptions;
import com.azure.messaging.servicebus.models.CreateMessageBatchOptions;
import com.utils.core.logging.ILogger;
import com.utils.core.logging.LogLevels;
import com.utils.core.models.azure.servicebus.AzureServiceBusCredentialsModel;
import javax.inject.Inject;
import java.time.Duration;
import java.util.HashMap;
import java.util.List;
import java.util.ServiceLoader;


public class AzureServiceBusClient {
    private final ServiceBusProcessorClientOptions processorClientOptions;
    private final TracerProvider tracerProvider = new TracerProvider(ServiceLoader.load(Tracer.class));
    private ILogger log;
    private AzureServiceBusCredentialsModel azureServiceBusCredentialsModel;
    private ServiceBusSenderClient senderClient;
    private ServiceBusReceiverClient receiverClient;
    private static final int maxAutoLockRenewDuration = 1; // 1 minute
    private static final int MAX_SERVICE_BUS_CONCURRENT_CALLS = 10;
    private static final int MAX_MESSAGE_DOWNLOAD_COUNT = 10;

    @Inject
    public AzureServiceBusClient(AzureServiceBusCredentialsModel azureServiceBusCredentialsModel,
                                 ILogger logger) {
        this.azureServiceBusCredentialsModel = azureServiceBusCredentialsModel;
        this.processorClientOptions = new ServiceBusProcessorClientOptions()
                .setMaxConcurrentCalls(azureServiceBusCredentialsModel.getMaxConcurrentCalls() > 0 ?
                        azureServiceBusCredentialsModel.getMaxConcurrentCalls() : MAX_SERVICE_BUS_CONCURRENT_CALLS)
                .setTracerProvider(tracerProvider);
        this.log = logger;

        // Build the sender client
        this.senderClient = new ServiceBusClientBuilder()
                .connectionString(azureServiceBusCredentialsModel.getServiceBusConnectionString())
                .sender()
                .topicName(azureServiceBusCredentialsModel.getTopicName())
                .buildClient();
    }

    /*
     * Function to send Service Bus messages to topic
     * @param serviceBusMessages: List of messages to be sent in batch
     */
    public void sendMessages(List<ServiceBusMessage> serviceBusMessages) {

        // Iterate through messages
        HashMap<String, String> messageProperties = new HashMap<>();

        try {

            // Creates an ServiceBusMessageBatch where the ServiceBus.
            // If no maximumSizeInBatch is set, the maximum message size is used.
            ServiceBusMessageBatch currentBatch = senderClient.createMessageBatch(
                    new CreateMessageBatchOptions().setMaximumSizeInBytes(1024));

            // We try to add as many messages as a batch can fit based on the maximum size and send to Service Bus when
            // the batch can hold no more messages. Create a new batch for next set of messages and repeat until all
            // messages are sent.
            for (ServiceBusMessage serviceBusMessage : serviceBusMessages) {
                if (currentBatch.tryAddMessage(serviceBusMessage)) {
                    continue;
                }

                // Clear the Hashmap
                messageProperties.clear();

                // Update the document metadata properties
                serviceBusMessage
                        .getApplicationProperties()
                        .forEach(
                                (key, value) -> {
                                    messageProperties.put(key, String.valueOf(value));
                                });

                // The batch is full, so we create a new batch and send the batch.
                senderClient.sendMessages(currentBatch);
                currentBatch = senderClient.createMessageBatch();

                // Add that message that we couldn't before.
                if (!currentBatch.tryAddMessage(serviceBusMessage)) {
                    log.trace(
                            String.format("Message is too large for an empty batch. Skipping. Max size: %s. Message: %s%n",
                                    currentBatch.getMaxSizeInBytes(), serviceBusMessage.getBody().toString()),
                            LogLevels.Verbose,
                            messageProperties);
                }
            }

            senderClient.sendMessages(currentBatch);
        } catch (Exception e) {
            // Handle exception here
            log.trace(
                    String.format(
                            "Error: %s occurred while publishing message to topic: %s",
                            e.toString(), azureServiceBusCredentialsModel.getTopicName()),
                    LogLevels.Verbose,
                    null);
        } finally {
            // Close the sender.
            senderClient.close();
        }
    }

}

Expected behavior
Message should be successfully sent to the desired topic

Screenshots
NA

Setup (please complete the following information):

  • OS: Ubuntu 18.04 LTS
  • IDE : IntelliJ
  • Version of the Library used: Java 1.8

Additional context
Used Keyvault shaded JAR as part of keyvault implementation.

    <dependencies>
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-security-keyvault-secrets</artifactId>
            <version>4.2.0</version>
        </dependency>
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-identity</artifactId>
            <version>1.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-core</artifactId>
            <version>1.7.0</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
        </dependency>
    </dependencies>

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [x] Bug Description Added
  • [x] Repro Steps Added
  • [x] Setup information Added
Azure.Core Client customer-reported question

All 5 comments

Hi @sudharsan2020, this looks to be a dependency conflict between the version of azure-core being included by azure-messaging-servicebus and what is included in the shaded JAR. Could you update the dependencies, and remove the azure-core dependency, in the shaded JAR to the following and see if it resolves the issue.

<dependencies>
    <dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-security-keyvault-secrets</artifactId>
        <version>4.2.3</version>
    </dependency>
    <dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-identity</artifactId>
        <version>1.2.0</version>
    </dependency>
</dependencies>

@alzimmermsft
Thanks for the update. But I am _still getting the same error_ after removing the azure-core from the Keyvault shaded library implementation. keyvaultshaded.zip

Updated Keyvault shaded pom.xml:

    <dependencies>
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-security-keyvault-secrets</artifactId>
            <version>4.2.3</version>
        </dependency>
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-identity</artifactId>
            <version>1.2.0</version>
        </dependency>
    </dependencies>

Updated application pom.xml:
_Moved the azure-core_ dependency form the Keyvault shaded to the application.
pom.xml: https://www.codepile.net/pile/Mle7MOVO

Can you please do the needful?

@alzimmermsft Saw a similar issue in the forum. Not sure if it's related to Azure identity and Service Bus package version conflict? https://github.com/Azure/azure-sdk-for-java/issues/17942

@alzimmermsft Saw a similar issue in the forum. Not sure if it's related to Azure identity and Service Bus package version conflict? #17942

This isn't related to that issue.

I've dug into this further and I believe it is an issue with the shaded JAR and the project resolving to the same version of azure-core. Adding azure-core:1.11.0 resolve this issue for me in testing, could you try it on your end as well.

@alzimmermsft Upgrading the azure core helped me to solve the issue. Thanks a lot for your support

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abelmariam picture abelmariam  路  4Comments

buchizo picture buchizo  路  4Comments

dkirrane picture dkirrane  路  4Comments

Shabirmean picture Shabirmean  路  3Comments

srnagar picture srnagar  路  4Comments